比如 B< List<T> > : public A<T>class A <P, C> {
P getParent();
C[] getChilds();
}class B<P extends (自己), C> : public <P, C> {
}当然可以 extends B ,不加泛型参数,没有更好的方法么?
随便问句,带泛型参数的Collection类没办法直接实例化数组么?
如 Map<K,V> p[] = new HashMap<K,V>[]?
P getParent();
C[] getChilds();
}class B<P extends (自己), C> : public <P, C> {
}当然可以 extends B ,不加泛型参数,没有更好的方法么?
随便问句,带泛型参数的Collection类没办法直接实例化数组么?
如 Map<K,V> p[] = new HashMap<K,V>[]?
List <String > list=new ArrayList<String>();
这个就是创建列表数组的String类型的
应该是JAVA的吧。。楼主说呢
当然是JAVA的class A<T> {
}限定T必须是A的继承类class A<T extends A<?> > {
}是这样么?
如 Map<K,V> p[] = new HashMap<K,V>[]?————————————————————————————————————————由于类型安全原因,不允许声明泛型数组,但可以这样:Map<String, String>[] map = new Map[5];
for(int i = 0; i < map.length; i++) {
map[i] = new HashMap<String, String>();
}