[問題] Generic array
code 大概長這樣
public Gene<E>{
private E e;
public Gene(){
e = null;
}
public static void main(String args[]){
Gene<Integer> [] g = new Gene<Integer> [10];
}
}
請問這樣為啥會出現
Gene.java:7: generic array creation
這個error..
一般來說generic array 不能寫 應該是不能寫成 E[] test = new E[10];
之類的樣子吧
我這種寫法 在 compile time 就可以決定形態 配置空間 為啥javac不給過勒@@
謝謝!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 58.114.85.48
→
01/26 20:13, , 1F
01/26 20:13, 1F
推
01/26 22:49, , 2F
01/26 22:49, 2F
推
01/27 23:18, , 3F
01/27 23:18, 3F
→
01/28 22:28, , 4F
01/28 22:28, 4F