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.
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 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.
Joined: Oct 13, 2005
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.
Joined: Mar 05, 2008
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.
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').