TreeSet The underlying data structure is balanced tree. Duplicate objects are not allowed. All elements will be inserted, according to some sorting order hence insertion is not preserve. Heterogeneous objects are not allow, violation leads ClassCastException. Constructors:- TreeSet t = new TreeSet (); // natural sorting order. creates an empty TreeSet object where all the […]
Month: December 2018
SortedSet
SortedSet It is the child interface set. If we want to represent a group of objects without duplicates, according to some sorting order, then we should go for SortedSet interface. The sorting order can be natural sorting order or customized sorting order. SortedSet defines the following six specific methods. Object first (); Object last (); […]
Set
Set It is the child interface of collection. If insertion order is not required & duplicate objects are not allowed. Then we should go for set interface. Set interface doesn’t contain any new method, hence we have to use only collection interface method. * image * Constructor HasSet h = new […]
Stack
Stack It is the child class of vector & contains only or constructor. Stack s =new stack () Method of stack:- Object push ( object o ) // for inserting an object Object pop ( object o ) // remove &returns top of the stack Object Peek () // returns top of the stack with […]
Vector
Vector The underlying data structure is resizable or growable array. Insertion order is preserve. Duplicate objects allow. Null insertion is possible. Heterogeneous objects are allow. Vector class implements Serialization, Cloneable & RandomAccess interface. Best suitable for frequent operation is retrieval. Worst choice is Frequent operation is insertion or deletion on middle. Every method present in […]
LinkedList
LinkedList The underlying data structure for LinkedList is double LinkedList. Insertion order is preserve. Duplicate objects are allowed. Heterogeneous objects are allowed. Null insertion is possible. Implements Serializable & Cloneable interface but not Random Access. LinkedList is not suitable if our frequent operation is not retrieval operation. Constructors:- LinkedList l = new LinkedList (); creates […]
Array List
Array List The underlying data structure is resizeable Array or growable Array. Insertion order is preserved. Duplicate objects are allowed. Hetrogenious objects are allowed. Null insertion is possible. Constructors of ArrayList ArrayList l = new ArrayList () ↔ creates an empty ArrayList object with default intial capacity 10. ↔ If arraylist reaches its max […]
Vector
Vector The underlying data structure is resizable or growable Array. Insertion order is preserve. Duplicate objects are allow. Null insertion is possible. Hetrogenious objects are allow. Vector class implements Serializable, Clonable & RandomAccess interface. Best suitable for frequent operation is retrieval. Worst choice is frequent operation is insertion or deletion on middle. Every method present […]
Collection Framework
Limitations of Object Array:- ⇒ Arrays are fixed in size i.e once we created an array there is no chance of increasing or decreasing the size our requirement i.e if we don’t know the size in advance, arrays are not recommended to use. ⇒ Arrays can hold only homogeneous data elements. Student [] s = […]
Static Import
Static Import This concept is introduces in 1.5, According to static import, improves readability of the code. But According to world wide experts, static import reduces readability and increases the confusion of the code. Hence if there is no specific requirement, it is not recommended to use static import. When we are using static import, […]