我有一个示例代码try.The代码似乎没有编译错误。为什么它使用静态嵌套类节点?当我删除static
中的Node
嵌套类并编译时,错误显示create generic array
在private Node[] next = new Node[R];
中。究竟发生了什么?为什么静态嵌套类?
public class TrieST<Value> {
private static final int R = 256; // extended ASCII
private Node root; // root of trie
private int N; // number of keys in trie
// R-way trie node
private static class Node {
private Object val;
private Node[] next = new Node[R];
}
public TrieST() {
}
}
首先,你知道为什么通用数组是不允许的吗? (例如'新ArrayList [5];'显示此错误) –
immibis
2015-02-12 01:58:21
可能的重复[如何创建通用数组?](http://stackoverflow.com/questions/18581002/how-to-create-a-generic -array) – alfasin 2015-02-12 02:15:03
你可以解释为什么添加静态时没有这样的错误? – Peterxwl 2015-02-12 02:18:02