代碼
提交代碼
@FunctionalInterface
interface TestFunctionalInterface
{
//抽象方法
public void doTest();
//java.lang.Object中的public方法
public boolean equals(Object obj);
public String toString();
//默認方法
public default void doDefaultMethod(){System.out.println("call dodefaultMethod");}
//靜態(tài)方法
public static void doStaticMethod(){System.out.println("call doStaticMethod");}
public static void main(String...s){
//實現(xiàn)抽象方法
TestFunctionalInterface test = ()->{
System.out.println("call doTest");
};
//調用抽象方法
test.doTest();
//調用默認方法
test.doDefaultMethod();
//調用靜態(tài)方法
TestFunctionalInterface.doStaticMethod();
//調用toString方法
System.out.println(test.toString());
}
}
運行結果