Skip to content
Snippets Groups Projects
HashMapSet.java 766 B
Newer Older
VIGNESH VIJAYAKUMAR's avatar
VIGNESH VIJAYAKUMAR committed
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
	}
}