摘要: public class GenericTest6 { @Test public void test01() { Object obj = null; String str = null; obj = str; Integer[] arr = null; Object[] arr2 = null; 阅读全文
posted @ 2020-09-11 23:19 温森 阅读(96) 评论(0) 推荐(0) 编辑
摘要: public class Student<T> { private T studentT; //静态方法中不能使用泛型 // public static void show(T studentT) { // System.out.println(studentT); // } public void 阅读全文
posted @ 2020-09-11 21:51 温森 阅读(330) 评论(0) 推荐(0) 编辑
摘要: 泛型方法:在方法中出现了泛型的结构,泛型参数与类的泛型参数没有任何关系,也就是说,泛型方法所属的类是不是泛型类都没有关系 //泛型方法:在方法中出现了泛型的结构,泛型参数与类的泛型参数没有任何关系 //也就是说,泛型方法所属的类是不是泛型类都没有关系 //下述方法才为泛型方法,注意格式 public 阅读全文
posted @ 2020-09-11 21:31 温森 阅读(441) 评论(0) 推荐(0) 编辑
摘要: 1. 静态方法中不能使用泛型 2. 泛型数组的正确写法 public class Student<T> { private T studentT; //静态方法中不能使用泛型 // public static void show(T studentT) { // System.out.println 阅读全文
posted @ 2020-09-11 20:34 温森 阅读(307) 评论(0) 推荐(0) 编辑