9
HashMap<UUID/String, Object> 

Which is better? I know UUIDs dont use that much memory but what is generally better to use?

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
ntakouris
  • 898
  • 1
  • 9
  • 22

2 Answers2

12

UUID takes up less space than the String does. Storing UUID itself via HashMap<UUID, MyObject> will conserve the space compared to HashMap<String, MyObject>.

Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
6

In general, the more specialized a type, the less waste there is, both regarding algorithms and storage.
Also, the data gets easier to manipulate.

Thus, if you know your argument is always a UUID, don't go for strings instead.

Ignoring that advice leads to a loosely typed mess, in extreme cases also known as stringly-typed-programs.

http://blog.codinghorror.com/new-programming-jargon
http://c2.com/cgi/wiki?StringlyTyped

cat with strings

Community
  • 1
  • 1
Deduplicator
  • 44,692
  • 7
  • 66
  • 118