java基础 接口静态方法

 1 /**
 2  * 从java8开始,接口当中允许定义静态方法
 3  * 格式:
 4  * public static 返回值类型 方法名称(参数列表){
 5  *     方法体
 6  * }
 7  * 提示:就是将abstract或者default换成static即可,带上方法体
 8  * 注意:不能通过接口实现类的对象来调用接口当中的静态方法。
 9  * 正确用法:
10  * 通过接口名称,直接调用其中的静态方法
11  * 接口名称.静态方法名(参数);
12  */
13 public interface MyInterfaceStatic {
14 
15     public static void main(String[] args) {
16         System.out.println("接口中的静态方法");
17     }
18 }

猜你喜欢

转载自www.cnblogs.com/mantishell/p/11774290.html