Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Sample HashMap

import java.util.Map;
import java.util.HashMap;

class Main {

    public static void main(String[] args) {
        // Creating a map using the HashMap
        Map<String, Integer> numbers = new HashMap<>();

        // Insert elements to the map
        numbers.put("One", 1);
        numbers.put("Two", 2);
        System.out.println("Map: " + numbers);

        // Access keys of the map
        System.out.println("Keys: " + numbers.keySet());

        // Access values of the map
        System.out.println("Values: " + numbers.values());

        // Access entries of the map
        System.out.println("Entries: " + numbers.entrySet());

        // Remove Elements from the map
        int value = numbers.remove("Two");
        System.out.println("Removed Value: " + value);
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: Implementing the Stack Class in java list 
Java :: how to get the memory location of an object in java 
Java :: how to disable the cors in spring boot 
Java :: how to create search function in android studio 
Java :: char value java 
Java :: array de meses java 
Java :: what is arraylist 
Java :: java run jnlp 
Java :: change brightness of image in java 
Java :: Compare two csv files using java 
Java :: java string equals null 
Java :: width and height of screen java 
Java :: android snackbar message is behind back button 
Java :: Java if...else 
Java :: seek bar 
Java :: maths.random in Java 
Java :: for each loop in java 
Java :: Java 2-dimensional Array 
Java :: android studio int ot string 
Java :: Java Creating an EnumMap 
Java :: how to skip a line with a filewriter java 
Java :: mongorepository spring boot custom query 
Java :: how to find lcm of two numbers java 
Java :: get ocurrences in array java 
Java :: how to get length of 2d array java 
Java :: How to Initialize Arrays in Java? 
Java :: CORS with Spring Boot 
Java :: enum class in java 
Java :: spring boot basic authentication 
Java :: java hashmap set value 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =