What you are describing is an associative array also called a table, dictionary, or map.
In Java, you need the Map interface and possibly the HashMap class as an implementation.
Map<String, Integer> myMap = new HashMap<String, Integer>(); myMap.put("cat", 123); Integer value = myMap.get("cat");
source share