Buckets accurately represent an array of nodes. Thus, one bucket is an instance of the java.util.HashMap.Node class. Each Node is a LinkedList-like data structure, or can be like a TreeMap (starting with Java 8), HashMap decides what is best for performance - save the buckets as LinkedList or TreeMap. TreeMap will be selected only in case of a poorly designed hashCode () function, when many records will be placed in one bucket. See what buckets look like in a HashMap:
/** * The table, initialized on first use, and resized as * necessary. When allocated, length is always a power of two. * (We also tolerate length zero in some operations to allow * bootstrapping mechanics that are currently not needed.) */ transient Node<K,V>[] table;
source share