[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Java: How to print out a hash map?

Posted on 2004-11-24
3
Medium Priority
?
252 Views
Last Modified: 2010-04-17
I have a hash map. I don't know how to print it out.
Thank you
0
Comment
Question by:coolgem
  • 2
3 Comments
 
LVL 19

Expert Comment

by:ramazanyich
ID: 12670688
If you want simple output then just use use System.out.print(yourmap);
0
 
LVL 19

Accepted Solution

by:
ramazanyich earned 1000 total points
ID: 12670705
If you want another output you can use iterator:
                HashMap map = new HashMap();
                map.put("test","value");
      Iterator it = map.keySet().iterator();
      while(it.hasNext()){
         Object key=it.next();
         Object value=map.get(key);
         System.out.println("key:"+key+";value"+value);
      }
0
 

Author Comment

by:coolgem
ID: 12681492
Thank you ramazanyich
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Make the most of your online learning experience.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Starting up a Project

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question