2:06 am - Tuesday April 23, 2019

HashMap Example program for put(k key,V value)

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
*@description:HashMap Example Program for put(k key,v value)
**/

import java.util.HashMap;

public class Put
{
public static void main(String[] args)
{
// Create a HashMap with three key/value pairs.
HashMap hm = new HashMap();
hm.put("One", new Integer(1));
hm.put("Two", new Integer(2));
hm.put("Three", new Integer(3));

/*Iterate over the HashMap to see what we just put in.
Set set = hm.entrySet();
Iterator setIter = set.iterator();
while (setIter.hasNext())
{
System.out.println(setIter.next());
}*/
}
}/**
*@author:candidjava
*@description:HashMap Example Program for put(k key,v value)
**/

import java.util.HashMap;

public class Put
{
public static void main(String[] args)
{
// Create a HashMap with three key/value pairs.
HashMap hm = new HashMap();
hm.put("One", new Integer(1));
hm.put("Two", new Integer(2));
hm.put("Three", new Integer(3));

/*Iterate over the HashMap to see what we just put in.
Set set = hm.entrySet();
Iterator setIter = set.iterator();
while (setIter.hasNext())
{
System.out.println(setIter.next());
}*/
}
}

Output:

[One, 1]
[Two, 2]
[Three, 3]

Filed in: Z-A All Java Codes

Comments are closed.