Since with static you create: Node[] next = new Node[R] and with a non-stationary inner class, you create a Node that is associated with an instance of an outer class that has a common type. And creating shared arrays is forbidden.
But back to a few steps: the way to create an inner class (non-static) is as follows (example):
class TrieST<V> { private static final int R = 256; private Node root;
Now, if we try to change the above implementation from an instance of the inner class to an array, we get the creation of a common array , since it prohibits creating arrays with a common type due to the covariance nature of arrays ( Shape[] is super of Triangle[] ), which is not works very well with the invariant nature of generics ( List<Object> not super of List<String> ). In Effective Java, Bloch provides a more detailed explanation if you want to look into it.
If you insist on using an inner class, you can get around this limitation using Array.newInstance() , which can create an array of a type known only at runtime, as follows:
private Node[] next = (Node[]) Array.newInstance(Node.class, R);
source share