![jajba collection jajba collection](https://i0.wp.com/53sports.com/wp-content/uploads/2020/07/Jazba-SKYDRIVE-290-Red.jpg)
We have stored the returned value in string variable because in our example we have defined the ArrayList is of String type. String str= obj.get(2) įunction get would return the string stored at 3rd position (index 2) and would be assigned to the string “str”. This would give the index (position) of the string Tom in the list.ħ) Object get(int index): It returns the object of list which is present at the specified index. If the element is not found in the list then this method returns the value -1. It would replace the 3rd element (index =2 is 3rd element) with the value Tom.Ħ) int indexOf(Object o): Gives the index of the object o. It replaces the element present at the specified index with the object o. It would remove the element of index 3 (4th element of the list – List starts with o).ĥ) set(int index, Object o): Used for updating an element. This statement will remove the string “Chaitanya” from the ArrayList.Ĥ) remove(int index): Removes element from a given index. It will add the string bye to the 2nd index (3rd position as the array list starts with index 0) of array list.ģ) remove(Object o): Removes the object o from the ArrayList. This statement would add a string hello in the arraylist at last position.Ģ) add(int index, Object o): It adds the object o to the array list at the given index. It contains only one Abstract method ie.,įew important methods of ArrayList class.ġ) add( Object o): This method adds an object o to the arraylist.
![jajba collection jajba collection](https://www.wholesaletextile.in/product-img/9d22709f-2b68-4654-892e-6bccc17d683e1553334023.jpg)
It returns the element and moves the cursor pointer to the next element. It returns true if the iterator has more elements otherwise it returns false. There are only three methods in the iterator interface ,they are S.no Iterator interface provides the facility of iterating the elements in a forward direction only ("retain the element:"+ab.retainAll(ab)) ("Removeall the element "+ab.removeAll(ab))
#Jajba collection code
It returns the hash code number of the collection. It is used to search the specified collection in the collection. It removes the total number of elements from the collection. It returns the total number of elements in the collection. It is used to delete all the elements of invoking collection except the specified collection. It is used to delete all the elements of the specified collection from the invoking collection. It is used to delete an element from the collection. It is used to insert the specified collection elements in the invoking collection. It is used to insert an element in this collection. There are many methods declared in the collection interface ,they are as follows S.no The java.utill package contains all the classes and interface for collection framework. The collection framework represents a unified architecture for strong and manipulating a group of objects ,it hasġ.interface and its implementations ,ie…, classes