day10-接口的静态方法的定义和使用
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package com.inmind.interface_static03;
|
||||
/*
|
||||
接口中的静态方法的使用:
|
||||
只能通过接口名.静态方法(参数列表)直接调用
|
||||
*/
|
||||
public class Demo03 {
|
||||
public static void main(String[] args) {
|
||||
//调用静态方法(接口名.静态方法(参数列表)直接调用)
|
||||
MyInterface.method1();
|
||||
MyInterface.method2();
|
||||
//能不能使用对象来强制调用???绝对不行,只能通过定义静态方法的接口调用!!!!
|
||||
/*MyInterfaceImpl myInterface = new MyInterfaceImpl();
|
||||
myInterface.method1();
|
||||
MyInterfaceImpl.method1();*/
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user