博文

目前显示的是标签为“java 8”的博文

Interface in Java 8

1.Default Methods in Interfaces Java 8 introduced a new keyword default. Now you’re allowed to write a default implementation of a method in the interface. Such a method won’t be considered abstract anymore, and you won’t be forced to implement it in your class. 2.Static Methods in Interfaces Starting from Java 8, interfaces are also allowed to include static methods, which are not specific to any instance and can be used only internally by other methods of the interface. public interface testInter { public void test1 ( int i ); public default void test2 ( int i ){ System . out . println ( "Default Method!" ); if(isJUNE()){System.out.println("There is a Static Method.");}  }; //S tatic Method,which are not specific to any instance //and can be used only internally by other methods of the interface. static boolean is JUNE (){ Month month = LocalDate . now (). getMonth (); if ( month ...