Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Lambda expressions - Rationale and examples found here

 
Ranch Hand
Posts: 54
Clojure Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For folks who are just wondering what this JSR is about, you might want to have a look at Brian Goetz's informal overview, found here:

Brian Goetz's overview of JSR-335 (December 2011)

He is the captain of the project, besides a very good writer.

HTH,
Rick
 
Marshal
Posts: 65423
248
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a more recent version here, also by Brian Goetz. That makes fascinting reading, and I haven't read it all yet. It has some things I had never seen before, including the List#stream method and comparing methods in the Comparator interface. Those methods appear to be static, which is something I had never seen before.
Actually the stream method appears to belong to Collection.
 
Rick Goff
Ranch Hand
Posts: 54
Clojure Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's the link to the latest version:

http://cr.openjdk.java.net/~briangoetz/lambda/lambda-state-final.html

Oops, sorry Campbell. Just saw you had already included the link.

 
Sheriff
Posts: 21784
104
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Those methods appear to be static, which is something I had never seen before.


Static and default methods in interfaces are new in Java 8. The first is pretty obvious, the second means you can add a method to an interface with a default implementation. Collection.stream() is one such method. This adds great flexibility in extending existing interfaces; you no longer need to worry about implementing classes breaking because they will simply inherit the default implementation from the interface (that's right - inheriting from an interface!).
 
Campbell Ritchie
Marshal
Posts: 65423
248
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does that mean that Java8 interfaces work rather like abstract classes?
Does that mean that Java8 classes can inherit implemented methods from two interfaces?
 
Master Rancher
Posts: 3317
31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Does that mean that Java8 interfaces work rather like abstract classes?


Somewhat, yes. The details are different, but they both can contain partial implementations.

Campbell Ritchie wrote:Does that mean that Java8 classes can inherit implemented methods from two interfaces?


Yes. However, they can inherit only one implementation of a particular method signature. They have rules for resolving any apparent conflicts.
 
Campbell Ritchie
Marshal
Posts: 65423
248
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope that mean there will be a new JLS with those disambiguation rules in. I see the keyword default has a new use, too. It is in the Brian Goetz link I posted.
 
Mike Simmons
Master Rancher
Posts: 3317
31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:I hope that mean there will be a new JLS with those disambiguation rules in.


Sure. They always do that for significant language changes, and Java 8 has some of the biggest they've ever had. You can see the text of proposed JLS changes in the Early Draft Specification link provided in the Goetz article, third sentence.
 
Bartender
Posts: 4101
63
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With the changes to core libraries/interfaces like the default methods in collections interfaces etc...
Lambda is the single largest upgrade to the model in Java stated by Mark Reinhold (even larger than generics').
 
Let's get him boys! We'll make him read this tiny ad!
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!