In PHP I could use an array with strings as keys. eg
$some_array[“cat”] = 123;
$some_array[“dog”] = 456;
I just switched to Java and I can’t find a data structure capable of doing this. Is this possible?
In PHP I could use an array with strings as keys. eg $some_array[cat] =
Share
What you are describing is an associative array, also called a table, dictionary, or map.
In Java, you want the
Mapinterface, and probably theHashMapclass as the implementation.