day10-接口的抽象方法的定义和使用
This commit is contained in:
@@ -1,4 +1,17 @@
|
||||
package com.inmind.interface01;
|
||||
|
||||
/*
|
||||
接口的抽象方法的使用步骤:
|
||||
1.接口不能创建对象的,它没有构造方法
|
||||
2.定义一个实现类,实现该接口,并实现接口中的所有的抽象方法
|
||||
public class MyInterfaceImpl(实现类) implements MyInterface(接口){
|
||||
3.创建该接口的实现类的对象,调用接口的方法
|
||||
*/
|
||||
public class Demo01 {
|
||||
public static void main(String[] args) {
|
||||
//MyInterface myInterface = new MyInterface();接口不能创建对象的
|
||||
//创建该接口的实现类的对象,调用接口的方法
|
||||
MyInterfaceImpl myInterface = new MyInterfaceImpl();
|
||||
myInterface.method();
|
||||
myInterface.method1();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user