To get value from a key in
HashMap
in Java, use the get
method.Here's how you do it:
java.util.Map<String, String> map = new java.util.HashMap<>();
map.put("greeting", "Hello World!");
String greeting = map.get("greeting");
System.out.println(greeting); // Hello World!