The Main Collections KeyPoints in java
Collection is a group of objects. java.util package provides important types of collections. There are two fundamental types of collections they are Collection and Map. Collection types hold a group of objects, Eg. Lists and Sets where as Map types hold group of objects as key, value pairs Eg. HashMap and Hashtable.
Here the collections of classes and interfaces having some their own properties.They are
1.Heterogenious Objects:
TreeSet and TreeMap will allow different types of objects as Integer,String,Long and userdefined objects ..etc..
2. Insertion Order:
Only List and its Child Classes can follow the insertion order.
ChildClasses of List: LinkedList,LinkedHashSet,LinkedHashMap.
3. Duplication:
Only List and its Child Classes will allow the duplicate objects.
In Map only values will be allowed as duplicates and keys are not.
Map will allow once the null key and value.
If you given again the key,value it will be overriden in Map.
4. Sorting Order:
Only TreeMap and TreeSet Classes will follow the Sorted order.
These two classes implements SortedSet and SortedMap Interfaces.
5. Null Rejectance:
HashTable,TreeSet and TreeMap classes only..remaining will allow null.
6. Synchronized:
Vector,Stack,HashTable and Properties are Synchronized.
Collection is a group of objects. java.util package provides important types of collections. There are two fundamental types of collections they are Collection and Map. Collection types hold a group of objects, Eg. Lists and Sets where as Map types hold group of objects as key, value pairs Eg. HashMap and Hashtable.
Here the collections of classes and interfaces having some their own properties.They are
1.Heterogenious Objects:
TreeSet and TreeMap will allow different types of objects as Integer,String,Long and userdefined objects ..etc..
2. Insertion Order:
Only List and its Child Classes can follow the insertion order.
ChildClasses of List: LinkedList,LinkedHashSet,LinkedHashMap.
3. Duplication:
Only List and its Child Classes will allow the duplicate objects.
In Map only values will be allowed as duplicates and keys are not.
Map will allow once the null key and value.
If you given again the key,value it will be overriden in Map.
4. Sorting Order:
Only TreeMap and TreeSet Classes will follow the Sorted order.
These two classes implements SortedSet and SortedMap Interfaces.
5. Null Rejectance:
HashTable,TreeSet and TreeMap classes only..remaining will allow null.
6. Synchronized:
Vector,Stack,HashTable and Properties are Synchronized.