I was looking at the source of HashMap.
A HashMap
implements Serializable
.
Ok this is so that it can be peristed/transmitted as
The transient
keyword indicates that a field shouldn't be included in the serialized representation of a class. The Entry[]
table of a HashMap
is simply an acceleration structure - it allows for fast lookup of the stored entries.
The entire table itself doesn't need to be serialized, just the entries it contains, since the table can be rebuilt again when deserializing from the list of entries.