hashset in java hashset example in java hashset api hashset in java example hashset in java 6 hashset in java api hashset in java collections difference between hashset and treeset difference between hashset and hashmap hashset vs treeset in java hashset vs hashmap in java difference between hashset and treeset in java
difference between hashset and treeset in java with example hashset api in java hashset api 7 hashset example in java for sorting hashset in java collections example
Hash Set:
Hash set belongs to 1 - D collection frame work.
1)
An object
of hash set never allows duplicates.
2)
An object of Hash Set organizes the data in the form of hash table
by following hashing mechanism. We cannot determine in which order hash set
class object displays the data because internally follows hashing mechanism and
it is not disclosed by sun micro system. i.e undetermined form.
3)
The operations like insert or delete or update
are taking considerable amount of time i.e; more expensive operations.
4)
An object
of hash set will take more amount of time to retrieve the data to retrieve the
data i.e: retrieval time is more / slow.
5)
Creating hash Set is nothing but creating hash
set object .
Ex: HashSet hs=new HashSet();
Difference between
TreeSet and HashSet ?
TreeSet functionality is depends binary tree concept.
TreeSet object displays the data in sorted order by implementing SortedSet
interface methods.
HashSet Functionality is depends on Hashing Mechanism
Concept. HashSet 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
HashMap and HashSet ?
HashMap and HashSet
Functionality is depends on Hashing Mechanism Concept. HashMap and HashSet
object displays the data in Random order. Insertion, deletion and modification are takes
more amount of time. Retrieval time of hashmap is very slow.
But they differ in
such that HashSet belongs to 1 –D Collection frame work, HashMap belongs to 2 –
D collection frame work.
The Following java program which
illustrate the concept of HashSet :
// HashTreeSets.java
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();
While(itr.hasNext())
{
Object obj=itr.next();
System.out.println(“---“+obj);
}
}
}
Data Extraction Interfaces are as follows :
Data Extraction Interfaces are as follows :
1- D and 2-D Collection Frame work classes are
No comments:
Post a Comment