Why are interfaces allowed to have a main method in Java 8?
As stated in below code it works fine and produces output properly.
public i
I second the answer of @jb-nizet. There is no "desparate need" for this, but it removes an unnecessary restriction. E.g. one example is, that you can now declare a factory method within the interface:
public interface SomeService {
public static SomeService getInstance() {
// e.g. resolve via service provider interface
}
...
}
Before Java 8 we needed always a separate factory class. One favorite example is the google app engine API.