Skip to content
Snippets Groups Projects
Commit ebed98d9 authored by VIGNESH VIJAYAKUMAR's avatar VIGNESH VIJAYAKUMAR
Browse files

Hash Map

parent 2363557e
No related branches found
No related tags found
No related merge requests found
import java.util.HashMap;
import java.util.HashSet;
public class HashMapSet{
public static void main(String[] args){
System.out.println("----HashMap----");
HashMap<String,Integer> hashmap_obj = new HashMap<String,Integer>();
hashmap_obj.put("One",1);
hashmap_obj.put("Two",2);
hashmap_obj.put("Three",3);
hashmap_obj.put("Four",4);
hashmap_obj.put("Five",5);
System.out.println(hashmap_obj);
//looping hash map
for(String i:hashmap_obj.keySet()){
System.out.println("Key : "+i+", Values : "+hashmap_obj.get(i));
}
System.out.println(hashmap_obj.get("One"));
//hashmap_obj.set("One",22);//throw error set property not allowed
System.out.println("Size : "+hashmap_obj.size());
//Hash set is same as otherss, nothing big different
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment