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-27-2007, 09:22 PM
Member
 
Join Date: Jul 2007
Posts: 41
gabriel is on a distinguished road
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
Sponsored Links
  #2 (permalink)  
Old 07-27-2007, 11:28 PM
Senior Member
 
Join Date: Jul 2007
Posts: 134
brianhks will become famous soon enough
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
sridhar.mudiganti is on a distinguished road
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
sridhar.mudiganti is on a distinguished road
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
qiuweiwei is on a distinguished road
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
gabriel is on a distinguished road
thanks guys for the explanations
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
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 +3. The time now is 11:45 PM.


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