import java.util.*;
public class hashmapeg3{
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("HashMap after put(): ");
for(Map.Entry m : map.entrySet()){
System.out.println(m.getKey()+" "+m.getValue());
}
// get() method to get value
String value = map.get(1);
System.out.println("Value at index 1: " + value);
}
}
import java.util.HashMap;
class Main {
public static void main(String[] args) {
HashMap<Integer, String> languages = new HashMap<>();
languages.put(1, "Java");
languages.put(2, "Python");
languages.put(3, "JavaScript");
System.out.println("HashMap: " + languages);
// get() method to get value
String value = languages.get(1);
System.out.println("Value at index 1: " + value);
}
}