java hashmap put
// Java code to illustrate the put() method
import java.util.*;
public class Hash_Map_Demo {
public static void main(String[] args)
{
// Creating an empty HashMap
HashMap<Integer, String> hash_map = new HashMap<Integer, String>();
// Mapping string values to int keys
hash_map.put(10, "Geeks");
hash_map.put(15, "4");
hash_map.put(20, "Geeks");
hash_map.put(25, "Welcomes");
hash_map.put(30, "You");
// Displaying the HashMap
System.out.println("Initial Mappings are: " + hash_map);
// Inserting existing key along with new value
String returned_value = (String)hash_map.put(20, "All");
// Verifying the returned value
System.out.println("Returned value is: " + returned_value);
// Displayin the new map
System.out.println("New map is: " + hash_map);
}
}
Also in Java:
- java create folder
- java tester si un caractere est une lettre
- capcitor FERR_CLEARTEXT_NOT_PERMITTED
- has places api got deprecated???
- java shortest if else statement
- set java
- string contains java
- gson parse json
- binary number input in int java
- convert two bytes to int java
- floor in java
- java treeset
- threadsafe singleton pattern in java
- java how to get all threads
- processing sound library
- java string to double
- java replace element in list
- islowercase java
- gat environment variables java
- java get current date without time
- java.lang.ClassCastException: cannot be cast to javax.servlet.Servlet
- how take inputs in java with message
- java find biggest number in array
- Java.awt graphics tutorial