In order to reduce the clutter caused by numerous instantiations of anonymous types, I\'m exploring the possibility of leveraging Java 8 lambdas.
One important cons
Java 8 introduces a new concept of default method implementation in interfaces. This capability is added for backward compatibility so that old interfaces can be used to leverage the lambda expression capability of Java 8. For example, ‘List’ or ‘Collection’ interfaces do not have ‘forEach’ method declaration. Thus, adding such method will simply break the collection framework implementations. Java 8 introduces default method so that List/Collection interface can have a default implementation of forEach method, and the class implementing these interfaces need not implement the same.
public interface vehicle {
default void print(){
System.out.println("I am a vehicle!");
}
}