dictionary - What is a simple way to store mixed values as a key value pair in Java? -
i trying figure out way store mixed values key value pair.
what have far 2 level linkedhashmap. first level primary keys. names of items. each key linkedhashmap too. trying work. in second linkedhashmap need able store mixed values. example boolean, int, float.
any ideas how so?
also there better way achieve idea nested linkedhashmaps? me seemed best thing.
i don't have code, scratch paper right now.
thanks!
create custom class
, have required data types there.
declare map as:
map<string,yourcustomclass> mydatamap = new hashmap<string,yourcustomclass> ();
you can make <string, object>
make generic, can perform casting later on based on logic.
Comments
Post a Comment