package All.D13.Generic_;
public class Demon04 {
public static void main(String[] args) {
Teacher<Integer,String>f=new Student<>(123,"jack");
System.out.println("===========");
Student<Integer,String,Boolean>s=new Student<>(213,true);
}
}
class Teacher<T1,T2>{
T1 t1;
T2 t2;
public Teacher(T1 t1, T2 t2) {
this.t1 = t1;
this.t2 = t2;
System.out.println("t1的类型为"+this.t1.getClass());
System.out.println("t2的类型为"+this.t2.getClass());
}
}
class Student<T1,T2,T3> extends Teacher<T1,T3>{
public Student(T1 t1, T3 t2) {
super(t1, t2);
}
}
===========
t1的类型为class java.lang.Integer
t2的类型为class java.lang.String
===========
t1的类型为class java.lang.Integer
t2的类型为class java.lang.Boolean
image.png
package All.D13.Generic_;
public class Demon04 {
public static void main(String[] args) {
Teacher<Integer,String>f=new Student<>(123,"jack");
System.out.println("===========");
Student<Integer,String,Double>s=new Student<>(213,"qwe");
}
}
class Teacher<T1,T2>{
T1 t1;
T2 t2;
public Teacher(T1 t1, T2 t2) {
this.t1 = t1;
this.t2 = t2;
System.out.println("t1的类型为"+this.t1.getClass());
System.out.println("t2的类型为"+this.t2.getClass());
}
}
class Student<T1,T2,T3> extends Teacher<T1,String>{
public Student(T1 t1, String t2) {
super(t1, t2);
}
}
package All.D13.Generic_;
public class Demon04 {
public static void main(String[] args) {
Teacher<Integer,String>f=new Student<>(123,"jack");
System.out.println("===========");
Student<Integer,String,Double>s=new Student<>(213,"qwe");
}
}
class Teacher<T1,T2>{
T1 t1;
T2 t2;
public Teacher(T1 t1, T2 t2) {
this.t1 = t1;
this.t2 = t2;
System.out.println("t1的类型为"+this.t1.getClass());
System.out.println("t2的类型为"+this.t2.getClass());
}
}
class Student<T1,T2,T3> extends Teacher<Integer,String>{
public Student(Integer t1, String t2) {
super(t1, t2);
}
}
==========
image.png
网友评论