Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

hashmap key check

// Java code to illustrate the containsKey() 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);
  
        // Checking for the key_element '20'
        System.out.println("Is the key '20' present? " + 
        hash_map.containsKey(20));
  
        // Checking for the key_element '5'
        System.out.println("Is the key '5' present? " + 
        hash_map.containsKey(5));
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: how to do the maximum of three numbers in java 
Java :: float maximum value java 
Java :: java how to cast int to String 
Java :: opacity in android studio 
Java :: how to use input in java 
Java :: swing setbounds 
Java :: java print hello world 
Java :: how to check whether a character is alphabet or not in java 
Java :: java arithmetic operators 
Java :: java list contains object with property 
Java :: bytes to string solidity 
Java :: object to int java 
Java :: Java, how to compare Strings with String Arrays 
Java :: linux command to see all the java version installed 
Java :: retrofit implementation 
Java :: java numbers 
Java :: java stream distinct by key 
Java :: how to resize image in java swing 
Java :: android recyclerview item click listener 
Java :: counting repeated characters in a string in java 
Java :: square root of a number in java without sqrt 
Java :: java declare array 
Java :: get the image from camera click in android 
Java :: how to print something in java 
Java :: intent pick action video android 
Java :: java subscript numbers 
Java :: resize image icon to fit jlabel 
Java :: intellij 
Java :: integer.tostring java 
Java :: java how to compare strings 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =