1、泛型类的静态上下文中类型变量失效。
//静态域或者方法里不能引用类型变量 private static t instance; //静态方法 本身是泛型方法就行 private static <t> t getinstance(){ }
2、不能实例化类型变量。
// public restrict() {// this.data = new t();// }
3、不能用基本类型实例化泛型参数。
// normalgeneric<double> normalgeneric = new normalgeneric<>(); normalgeneric<double> normalgeneric = new normalgeneric<>();
4、不能创建参数化类型的数组。
restrict<double>[] restrictarray; restrict<double>[] restricts = new restrict<double>[10];
以上就是java泛型的限制是什么?的详细内容。