CollectionsNotes
CollectionsNotes
Arrays :-
Limitations of Arrays
1. Fixed in size .
2. Can hold only homogeneous data type element.
for hetrogenous data with have to take Object Array.
3. No underline dataStructure (readymade method support not possible).
Collection
1. Growable in nature .
2. Can hold both Homogeneous and heterogeneous objects.
3. Standard Data Sturcture (ReadyMade Method support are there).
Array
1. Fixed in Size but collections are growable in nature
2. With respect memory arrays are not remmomemded but collections are recommened
to use.
3. Performance wise Arrays are good but collections are not .
4. Array can hold only Homogeneous but collections can hold both homo and hetro .
5. Underline DataStructure not avaible but in Collection there is standard DS.
6. primitives and objects both can be hold but in Collection only objects can be
hold.
Collection Vs Collections
1. Collection
2. List
Duplicate records are allowed and Insertion order is preserved.
List<Integer> list=new Stack<Integer>();
list=new LinkedList<Integer>();
list=new Vector<Integer>();
list=new ArrayList<Integer>();
3. Set
Duplicate records are not allowed and insertion order is not preserved.
Dupilcates are not allowed but elements are inserted in sorted order.
5. NavigableSet
6. Queue