【Map】 It is possible to hold the value associated with the key (name given to the value).
Since Map is an interface, you need to use an implementation class to instantiate it. This time, I used the commonly used HashMap class. Initialize as follows. Map <key type name, value type name> object name = new HashMap <> ();
Map<String, String> map1 = new HashMap<String, String>();
Then use "put" to add the value.
map1.put ("Spring", "Sakura"); map1.put ("summer", "sunflower"); map1.put ("Autumn", "Kinmokusei"); map1.put ("winter", "cyclamen");
When the value is output using "get", it becomes as follows.
String name1 = map1.get ("winter"); System.out.println(name1);