3:44 pm - Tuesday December 11, 9506

HashMap Example program for keySet()

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/**
Author :candidjava.com
Description: It returns a Set of keys of HashMap.
*/
import java.util.*;
public class HashMapkeySet
 {
public static void main(String arg[])
{
HashMap<Integer, String> osHashMap = new HashMap<Integer, String>(); // Create object  of hashmap
osHashMap.put(new Integer(1), "ABC");
osHashMap.put(new Integer(2), "DEF");
osHashMap.put(new Integer(3), "GHI");
Set osKeySet = osHashMap.keySet();
System.out.println("Set of Keys : " + osKeySet);
 }
 }

Output:

Set of Keys : [1, 2, 3]

BACK

Filed in: Z-A All Java Codes

Comments are closed.