s-day02-泛型接口的使用
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
package com.inmind.generic_interface07;
|
||||
|
||||
public class Demo10 {
|
||||
public static void main(String[] args) {
|
||||
//创建实现类1对象
|
||||
MyInterfaceImpl myInterface = new MyInterfaceImpl();
|
||||
myInterface.method("hello");
|
||||
//创建实现类2对象(在实现子类中不确定类型,在创建实现类对象时才确定类型)
|
||||
MyInterfaceImpl2<Integer> myInterface2 = new MyInterfaceImpl2<>();
|
||||
myInterface2.method(123);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user