4

Why does the following code result in a "generic array creation error" at compile time?

public class Trie<Value> {
    private class Node {
        private Node[] links = new Node[256];
        private Object val;
    }
}

Error message: Trie.java:3: error: generic array creation 
        private Node[] links = new Node[256];
Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
  • 1
    btw, if you don't need to access `Trie` fields in `Node`, you can(and should) make it static. And you will be able to create an array of them. – Vitalii Vitrenko Jul 21 '17 at 22:09

0 Answers0