Ads Sponsored By Google :)

Monday, 21 January 2013

difference|between|hashmap class and|vs hashtable example|code in java|6|7|1.6 collections|tutorial|api concurrent|map|implementation

hashmap in java hashmap example in java hashmap in java example concurrent hashmap in java hashmap implementation in java hashmap examples in java map and hashmap in java implementation of hashmap in java hashmap class in java difference between hashtable and hashmap in java difference between map and hashmap in java hashmap vs hashtable hashmap example in java collections hashmap in java 6 hashmap in java api hashmap in java tutorial difference between map and hashmap difference between hahstable and hashmap   hashmap in java example code iterator for hashmap in java example hashmap api java 7
hashmap api java 1.6

HashMap :

        1)      HashMap object organizes the data in the form of (key, value) pairs, where keys are 
        2)      HashMap follows hashing mechanism for organizing the data in the form of (key, value) 
        3)      We cannot determine in which order hashmap object displays the data i.e, undetermined                   
        4)      The operations like insertion / deletion  and modification are taking more amount of time 
                  i.e, more expensive.
        5)      Retrieval time of hashmap is more / slow.
        6)      Creating the hashmap is nothing but creating the object of Hashmap class.

            Ex : HashMap hm=new HashMap();

       Methods for hashmap that are inherited from Map interface. Methods in HashMap refer to    
       Java.Util.Map Interface

       Difference between HashMap and HashTable ?

        HashMap and HashTable is allows to organize the data in the form of (key, value) pair, 
      belongs to 2 – D collection frame work.
       HashMap is a class implemented from Map interface, it functionality depends on 
     hashing mechanism and it allows null values in (key,value) pairs, hashmap object belongs
     to non – synchronized.
          HashTree is a class implemented from Dictionary interface, it functionality depends on
    hashing mechanism and it allows null values in (key,value) pairs, hashmap object belongs to 

   The Following program illustrate the concept of HashMap Using Iterator Interface   
   retrieving the data :

     import java.util*;
      class hm
       Public static void main(String args[])
        HashMap hm=new HashMap();
        System.out.println(“Content of hm “+hm);
        System.out.println(“size of ht “+hm.size());
        //add the data to 2 –D CFW
        hm.put(new Integer(10),new Float(1.5f));
        hm.put(new Integer(100),new Float(2.5f));
        hm.put(new Integer(1),new Float(4.5f));
        hm.put(new Integer(90),new Float(11.5f));
       System.out.println(“Content of hm”+hm);
       System.out.println(“Size of hm”+hm.size());
       // extract the data from 2 –D CFW
      System.out.println(“Extract the data from  hm from enrtySet()àSetà iterator”);
      Set s=new hm.entrySet();
      iterator itr=s.iterator();
       Map.Entry me=(Map.Entry)mobj;// Object type Casting
       Object kobj=me.getKey();
       Object vobj=me.getValue();
       Integer io=(Integer)kobj;
       Float fo=(Float)vobj;
      System.out.println(“extract the data from htàkeySet()àSetàtoArray()”);   
      Set st=hm.keySet();
      Object kobj1[]=st.toArray();
        for(int i=0;i<kobj1.length;i++)
        Object vobj1=hm.get(kobj1[i]);
         Integer io1=(Integer)kobj1[1]);
         Float fo1=(Float)vobj1;
         int acno1=io1.intValue();
         float bal1=io1.floatValue();

 Data Extraction Interfaces are as follows :

          1- D and 2-D Collection Frame work classes are 

        To read the values dynamically from keyboard their is a class.
                 Java.util.Scanner or Scanner class

No comments:

Post a Comment