9:50 pm - Monday October 15, 2018

HashMap Example program for size()

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: total number of keys in HashMap.
*/
import java.util.*;
public class HashMapSize
 {
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");
System.out.println("Size of HashMap :" + osHashMap.size());
}
 }

Output:

Size of HashMap :3

BACK

Filed in: Z-A All Java Codes

Comments are closed.