Results 1 to 6 of 6

Thread: what is hashmap

  1. #1
    gabriel is offline Member
    Join Date
    Jul 2007
    Posts
    41
    Rep Power
    0

    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

  2. #2
    brianhks is offline Senior Member
    Join Date
    Jul 2007
    Posts
    135
    Rep Power
    0

    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"

  3. #3
    Join Date
    Jul 2007
    Posts
    2
    Rep Power
    0

    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.

  4. #4
    Join Date
    Jul 2007
    Posts
    2
    Rep Power
    0

    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...............

  5. #5
    qiuweiwei is offline Member
    Join Date
    Jul 2007
    Posts
    1
    Rep Power
    0

    Default

    please notice memory orde and read orde.

    i am chinese,i enlish is very bad. i am soory.

  6. #6
    gabriel is offline Member
    Join Date
    Jul 2007
    Posts
    41
    Rep Power
    0

Similar Threads

  1. HashTable vs HashMap
    By bugger in forum New To Java
    Replies: 7
    Last Post: 01-06-2011, 03:15 PM
  2. ArrayList into hashMap
    By Preethi in forum New To Java
    Replies: 2
    Last Post: 02-11-2008, 08:13 AM
  3. HashMap with objects
    By otoro_java in forum New To Java
    Replies: 2
    Last Post: 01-28-2008, 03:28 PM
  4. HashMap visual example
    By jhetfield18 in forum Advanced Java
    Replies: 1
    Last Post: 12-12-2007, 07:45 PM
  5. Hashmap
    By dirtycash in forum New To Java
    Replies: 5
    Last Post: 12-03-2007, 02:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •