Choose java abstract classes and interfaces

Standard: optional constructor required property or abstract class
Standard Two: does not meet the first, we chose interfaces


Java after 8, there is a default method for the interface will not affect the implementation class, with the default keyword, implementation class can be called directly

interface Example {
    default void fun() {
        System.out.println("happly");
    }
}

After 8 java, interfaces allow static method.

Guess you like

Origin blog.51cto.com/927343/2435518