A static inner class cannot access the (non-static) members of the containing class. But Node doesn't need to access these members - e.g. root. So Node could be static:
However, that means a static inner Node class has no access to the generic type parameters declared by the containing BST class.
So a static inner Node class must itself declare generic parameters:
public class BST<Key extends Comparable<Key>, Value> { private Node<Key, Value> root; private static class Node<K, V> { private K key; private V val; private Node<K,> left; private Node<K,V> right; public Node(K k, V v) { key = k; val = v; left = right = null; } public Node() { this(null); } } }