JAVA (Map)

【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);

[cyclamen]

Recommended Posts

JAVA (Map)
[Java] Map comparison
[Java] Stream API / map
Enum reverse map Java
Java
Java bidirectional map library
Java
[Java] How to use Map
[Java] How to use Map
How to use Java Map
Java learning (0)
[Java] array
Java protected
[Java] Module
Java array
Studying Java ―― 9
Java scratch scratch
Java tips, tips
[Java] Stream (filter, map, forEach, reduce)
Java methods
Java method
Java array
[Java] ArrayDeque
java (method)
Java Day 2018
Java string
java (array)
Java static
Java serialization
java beginner 4
JAVA paid
Studying Java ―― 4
Java (set)
java shellsort
[Java] compareTo
Studying Java -5
java reflexes
java (interface)
☾ Java / Collection
Java array
Studying Java ―― 1
[Java] Array
[Java] Polymorphism
Studying Java # 0
Java review
java framework
Java features
[Java] Inheritance
FastScanner Java
[Java] Collection-List / Set / Map / Stack / Queue
Get Null-safe Map values in Java
Java features
Map method
java beginner 3
Java memo
java (encapsulation)
Java inheritance
[Java] Overload
Java basics
Decompile Java
Use composite keys in Java Map.