Java for Testers - Part 222 - ArrayList in Detail
In this video, I have explained the below topics on ArrayList of Collections Framework in Java: * Child class of List Interface * All the methods of Parent interfaces are inherited * Purpose - Grouping individual objects * Adding objects into the ArrayList (Explain indexing) using add() method * Printing the ArrayList - [] * Retrieving the objects from the ArrayList using index using get() method * Object will be returned * Finding the size of the ArrayList using size() method * Using for loop for retrieving the objects * Using for-each loop for retrieving the objects * Duplicates are allowed * Insertion order is preserved * null insertion is allowed * Remove the objects from the ArrayList using remove(object) * ArrayList is a re-sizable Array * We can either add or remove the objects from the ArrayList * Heterogeneous objects are allowed by default * Storing specific type of objects by specifying the wrapper classes, String, Objects etc. * Primitive data types cannot be provided in Generics * Its not mandatory to provide the generic type at the object creation end * Removing all the ArrayList objects at a go using clear() method * Checking whether the ArrayList is Empty using isEmpty() method * Checking whether the provided object is available in the ArrayList using contains() method * Converting an ArrayList to Array using toArray() method * Adding at a particular index using add(index,object) method * Removing the object at a particular index using remove(index) method * Setting the required object at a particular index using set(index,newObject) * This will return the replaced object * Retrieving the index position of the given object using indexOf(Object) method * This will return -1 in case the given object is not available * Retrieving the last occurrence index of the duplicated object in the ArrayList using lastIndexOf(Object) method * Assigning the object of ArrayList to Collection interface * Assigning the object of ArrayList to List interface * Using Collections.sort() for soring the ArrayList objects * Using iterator() method with ArrayList * Using listIterator() method with ArrayList * Best suitable when your frequent operation is retrieval * Not suitable when your frequent operation is adding or removal of objects in between the ArrayList
Download
1 formatsVideo Formats
Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.