Ads Sponsored By Google :)

Tuesday, 22 January 2013

difference|between Treeset class and|vs hashset|treemap|sortedmap in java|6 example|api|program|code comparator comparable

Treeset in java Treeset in java example treeset example in java treeset vs hashset treeset class in java
treeset in java example Treeset in java 6 Treeset example in java comparator comparable Treeset example program in java Treeset vs hashset in java Treeset class example in java difference between treeset and hashset difference between treeset and hashset in java difference between treeset and treemap in java difference between treeset and sortedset difference between treeset and sortedset in java treeset class in java 6 treeset api in java 6 treeset in java example code

    Tree Set :
          1)          An object of tree set also never allows duplicates.
          2)       Tree set class object always organizes the data in the form of nodes by following 
              binary tree’s concept. An object of tree set class always displays the data in sorted order.
          3)      The operations like insertion / deletion / updation are taking very less amount of time.
          4)      Tree set class object takes less execution time i.e: retrieval time is less or fast.
          5)      Creating Tree Set is nothing but creating Tree set object .
               Ex:     TreeSet ts=new TreeSet();
    Difference between SortedSet and TreeSet ?
     TreeSet is one of the predefined class, And in which it takes the methods from SortedSet   
  interface. TreeSet class object displays the data in sorted order by implementing sorted set.
  SortedSet  is an interface which provide some functionality to TreeSet class by implementing 
  some methods into it.

   Difference between TreeSet and HashMap ?
     TreeSet  functionality is depends binary tree concept. TreeSet object displays the data in 
  sorted order by implementing SortedSet interface methods.
     HashMap Functionality is depends on Hashing Mechanism Concept. HashMap object   
 displays the data in Random order.  Insertion, deletion and modification are takes more 
 amount of time. Retrieval time of hashmap is very slow.

  Difference between TreeMap and TreeSet ?
    Both TreeMap and TreeSet Classes functionality are similar. They differ in TreeMap belongs to 2 – D collection frame work, TreeSet belongs to 1 – D Collection frame work.

     The Following java program which illustrate the concept of HashSet and TreeSet.
       Class HashTreeSets
        Public static void main(String args[])
         HashSet hs=new HashSet();
        //   TreeSet ts=new TreeSet();
         System.out.println(“Content of Hash or Tree Set”+hs); // [ ]
       System.out.println(“Size of Hash or Tree Set “+hs.size()); // 0
       // add the data to hs or ts
       hs.add(new Integer(10));
      hs.add(new Integer(100));
      hs.add(new Integer(90));
      hs.add(new Integer(1));
      hs.add(new Integer(10));// duplicates are not considered at runtime.
      System.out.println(“Content of hs”+ hs);
      System.out.println(“ Size of hs “+hs.Size());
     //Extracting the data
        Iterator itr=hs.iterator();

   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