HashMap savedStuff = new HashMap();
savedStuff.put("symbol", this.symbol); //this is a string
savedStuff.put("index", this.index); //this is an int
gives me the warning:
HashMap is a raw type. References to generic type HashMap<K,V> should be parameterized
I’m not sure what you’re trying to do, but since the example you provided uses hard-coded strings to index the data, it seems like you know what data you want to group together. If that’s the case, then a Map is probably not a good choice. The better approach would be to make a class out of the commonly grouped data:
This allows your client code to do this:
Rather than this:
The former example is much less fragile because you’re not indexing data with String constants. It also gives you a place to add behavior on top of your grouped data, which makes your code much more object oriented.