Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-19-2007, 04:57 PM
Member
 
Join Date: Jul 2007
Posts: 41
oregon is on a distinguished road
how to return values from hashmap
I want to retrieve all the values I put into a HashMap.
But I want them to retrieve them in the order I put them in.

Can you help me?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-20-2007, 07:23 AM
Member
 
Join Date: Jul 2007
Posts: 1
tirupati.j2ee is on a distinguished road
Hi
Hi

actually the basic implemantion of Hash map is there is no guarantiy to the order as per the the values you put . HashMap using hashtable functionality in thats way this is using index order and another thing is if you want get values from hash table ther are two vays one thing is to get the values set from hash map using value() method it terurn Collection object than after type costing each elemetn another one is using below code

HashMap<String, Integer> hmp= new HashMap<String, Integer>();
hmp.put("1", new Integer(1));
hmp.put("5", new Integer(5));
hmp.put("3", new Integer(3));
hmp.put("4", new Integer(4));
hmp.put("2", new Integer(2));
hmp.put("6", new Integer(6));

Set st = hmp.keySet();

//SortedSet st =keySet;
Iterator it = st.iterator();
while(it.hasNext())
{
System.out.println(hmp.get(it.next()));
}

System.out.println(hmp);
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 08-01-2007, 05:56 PM
Member
 
Join Date: Jul 2007
Posts: 41
oregon is on a distinguished road
excellent!! thanks a lot
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing boolean Values of another values in one class. a_iyer20 Advanced Java 4 04-15-2008 02:04 PM
HashMap: Obtaining all values in a collision? markus-sukram New To Java 2 03-29-2008 11:25 PM
HashMap String Return kizilbas1 New To Java 1 03-10-2008 04:34 AM
How to make a hashmap to allow duplicate values? Preethi New To Java 0 02-08-2008 01:35 PM
Hashmap dirtycash New To Java 5 12-03-2007 03:58 AM


All times are GMT +3. The time now is 11:51 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org