The main difference is not getting the elements but putting them.
If the elements are related to each other, for instance Name
, Age
and Sex
, encapsulating is better.
However, if they are tottaly different - which I think is not - you may use different maps.
My advice would be to make the class not private. A single line
map.put(Integer, new Element("John", 51, "Male"));
is better than
map1.put(Integer, "John");
map2.put(Integer, 51);
map3.put(Integer, "Male");