13 lines
473 B
Java
13 lines
473 B
Java
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);
|
|
}
|
|
}
|