HashMap savedStuff = new HashMap();
savedStuff.put(\"symbol\", this.symbol); //this is a string
savedStuff.put(\"index\", this.index); //this is an int
Using HashMap
is probably the best you can do if you insist on having heterogeneous values in the same map -- you'll need to cast those to do anything useful when you retrieve them (and how are you going to know what type to cast them to...?), but at least you'll be typesafe with respect to the keys.