[java][Solution] Using String as key in array or object

By.

min read

My profile

Share this:

I found this on the web [url]http://stackoverflow.com/questions/6943588/can-java-use-string-as-an-index-array-key-ex-arraya-1[/url]

Stating you should use a Map element/object. Which works great by the way 🙂

Small example ( this is non functional code as it needs methods, but you’ll get the point ).

[code:1:d10fb54949]import the whole lot:
import java.util.HashMap;
import java.util.Map;

init
protected Map<String> settings_xml = new HashMap<String>();

read:
settings_xml.get(thekey);

write:
settings_xml.put(thekey, thevalue);[/code:1:d10fb54949]

Share this:

Leave a Reply

Your email address will not be published. Required fields are marked *