[java] hashmap example

import java.util.HashMap;
import java.util.Iterator;

public class HashMapSample
{
public static void main(String[] args)
{
HashMap<Integer, String> hm = new HashMap<Integer, String>();

hm.put(1, “일”);
hm.put(2, “이”);
hm.put(3, “삼”);
hm.put(4, “사”);
hm.put(5, “오”);

Iterator iter = hm.keySet().iterator();

while(iter.hasNext())
{
int nCount    = iter.next();
System.out.println(hm.get(nCount));
}
}
}

result




Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s