I was asked in an interview to calculate the memory usage for HashMap
and how much estimated memory it will consume if you have 2 million items in it.
you can't know in advance without knowing what all the strings are, and how many items are in each list, or without knowing if the strings are all unique references.
The only way to know for sure, is to serialize the whole thing to a byte array (or temp file) and see exactly how many bytes that was.