File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Lambda Expressions - JSR335 and the fly likes Lambda expressions - Rationale and examples found here Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java JSRs » Lambda Expressions - JSR335
Bookmark "Lambda expressions - Rationale and examples found here" Watch "Lambda expressions - Rationale and examples found here" New topic
Author

Lambda expressions - Rationale and examples found here

Rick Goff
Ranch Hand

Joined: Nov 14, 2006
Posts: 54

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


OCPJP 6
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36508
    
  16
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

Joined: Nov 14, 2006
Posts: 54

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.

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

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!).


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36508
    
  16
Does that mean that Java8 interfaces work rather like abstract classes?
Does that mean that Java8 classes can inherit implemented methods from two interfaces?
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 2969
    
    9
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
Sheriff

Joined: Oct 13, 2005
Posts: 36508
    
  16
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
Ranch Hand

Joined: Mar 05, 2008
Posts: 2969
    
    9
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.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

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').


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
 
Don't get me started about those stupid light bulbs.
 
subject: Lambda expressions - Rationale and examples found here
 
Similar Threads
JSR's Approved
Difference between synchronizing a method and synchronizing a block of code in the method
Thread technology: Where it is mostly applicable? Can anyone give me some commercial example?
Java 7/8 finally proposed.
Order management system in j2me application