A default method is an interface method that adds new functionality and at the same time is backward compatible.
This is achieved with a default implementation, that doesn't break previous implementations of the interface. By defaut all the methods of an interface are abstract, however this is not the case of a default method.
public interface Runnable { void run(); default int getThreadId() { // implementation } }
You can extend an interface with a default method and:
Static methods are similar to default methods, but they are static and cannot be overridden.
public interface Runnable { void run(); static int getNumThreads() { // implementation } }
Copyright © 2013 Welcome to the website of Davis Fiore. All Rights Reserved.