s-day02-泛型接口的使用

This commit is contained in:
2026-07-31 11:13:44 +08:00
parent e6ac76cd25
commit 6bdf2742a2
4 changed files with 75 additions and 0 deletions
@@ -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);
}
}