Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-27-2007, 09:22 PM
Member
 
Join Date: Jul 2007
Posts: 41
Rep Power: 0
gabriel is on a distinguished road
Default what is hashmap
Could anyone explain to me what HashMap is? how it can be used. The simple syntax for setting it out.
thanks in advance
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 07-27-2007, 11:28 PM
Senior Member
 
Join Date: Jul 2007
Posts: 135
Rep Power: 0
brianhks will become famous soon enough
Default
A Map is like a dictionary in other languages. You have a key and you lookup a value using that key. Java has two kinds of Map's HashMap and TreeMap. The HashMap uses a hash of the key for lookups whereas the TreeMap uses a binary tree for storing the keys.

HashMap<String, String> myMap = new HashMap<String, String>();
myMap.put("FirstKey", "Bob");
myMap.put("SecondKey", "Sam");
System.out.println(myMap.get("FirstKey"));

This code should print out "Bob"
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-28-2007, 06:06 PM
Member
 
Join Date: Jul 2007
Posts: 2
Rep Power: 0
sridhar.mudiganti is on a distinguished road
Default
hash map is storing the values in the form of key,value pair.and it was not synchronized(means it can act upon many threads).intial capacity of hasmap is 16.and load factor is 0.75.
intial capacity*loadfactor=16*0.75=12
that means after storing the 12 th key vale pair hash map size is doubled.
and it allows duplicate values.
Hash map h=new Hashmap();
(123,"ajay") 1st one is key and followed by value.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-28-2007, 06:15 PM
Member
 
Join Date: Jul 2007
Posts: 2
Rep Power: 0
sridhar.mudiganti is on a distinguished road
Default
hi to every body i want learn java projct architecture.wat is the architecture nad how to represent to the interviewer.plz help me...............
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 07-28-2007, 09:53 PM
Member
 
Join Date: Jul 2007
Posts: 1
Rep Power: 0
qiuweiwei is on a distinguished road
Default
please notice memory orde and read orde.

i am chinese,i enlish is very bad. i am soory.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 08-03-2007, 02:23 PM
Member
 
Join Date: Jul 2007
Posts: 41
Rep Power: 0
gabriel is on a distinguished road
Default
thanks guys for the explanations
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

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

BB 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
ArrayList into hashMap Preethi New To Java 2 02-11-2008 09:13 AM
HashMap with objects otoro_java New To Java 2 01-28-2008 04:28 PM
HashMap visual example jhetfield18 Advanced Java 1 12-12-2007 08:45 PM
Hashmap dirtycash New To Java 5 12-03-2007 03:58 AM
HashTable vs HashMap bugger New To Java 3 11-29-2007 01:28 PM


All times are GMT +2. The time now is 03:08 PM.



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