Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

HashMap to store key and value pair.

import java.util.*;  
public class hashmapeg1{  
 public static void main(String args[]){  
   HashMap<Integer,String> map=new HashMap<Integer,String>();//Creating HashMap    
   map.put(1,"Cat");  //Put elements in Map  
   map.put(2,"Dog");    
   map.put(3,"Markhor");   
   map.put(4,"Peacock");   
       
   System.out.println("Iterating Hashmap...");  
   for(Map.Entry m : map.entrySet()){    
    System.out.println(m.getKey()+" "+m.getValue());    
   }  
}  
}
Comment

PREVIOUS NEXT
Code Example
Java :: java empty array list vs null elements 
Java :: array copy java 
Java :: de caracter a string en java 
Java :: all possible substrings of a string java of specific length 
Java :: what is object in java 
Java :: t implements comparable 
Java :: java exception to string 
Java :: java programme for fibonnaci series 
Java :: double if statement java 
Java :: maths.random in Java 
Java :: android studio space 
Java :: java loop through array 
Java :: swapping two numbers using third variable 
Java :: get field name java 
Java :: java check if string appears twice in arraylist 
Java :: math class in java 
Java :: java string replaceall for space 
Java :: mongorepository spring boot custom query 
Java :: java boolean data type 
Java :: lambda expression java 
Java :: Adding Entire ArrayList to another ArrayList in Java 
Java :: switch in java 
Java :: merge sort recursion java 
Java :: java draw image 
Java :: what is return method 
Java :: java array 
Java :: java check if array element is null 
Java :: writeToFileAsync java 
Java :: add checkbox box rows in tabulator 
Java :: first none duplicated char 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =