I apologize if the seems trivial but I always get confused on proper programming techniques. Sometimes there are too many ways to do one thing.
I have a HashMap <String, String>
to store most of my data. I have a double that I would like to store in the same map. My question is:
If possible is it better to convert the non string to a string and store it in the current data structure; or would it be better to store a HashMap<String, Object>
and cast the data accordingly when it gets used?
In this example would it be better to convert the Double
to a String
to store in the HashMap<String, String>
?
Or, store all the data in a HashMap<String, Object>
map and access it by casting data like this?
Double dub = (Double) map.get(doublekey);
I am using this in Android development and was wondering which is the preferred method of doing things.