How to get the Collection view of keys and values of Map?

import java.util.*;
class demo1
{
public static void main(String[] args){
HashMap hm=new HashMap();
hm.put(4,"bhabani");
hm.put(1,"samar");
hm.put(8,"gaura");
hm.put(3,"milan");
Set keyset=hm.keySet();//Map keys to a set
System.out.println(keyset);
Collection value=hm.values();//Map values to a collection
System.out.println(value);
}};

No comments:

Post a Comment