Example In this example we are converting a LinkedList to ArrayList. We have a LinkedList of Strings in which we are storing names of 5… [Read More]
Java – Convert Vector to ArrayList example
In this article, we will write a Java program to convert Vector to ArrayList. In Java, both Vector and ArrayList implement the List interface and… [Read More]
Java ArrayList set() Method
Java ArrayList set() method is used to replace an existing element present in the ArrayList at the specified position with the new given element. The… [Read More]
Java ArrayList trimToSize() Method
The trimToSize() method of ArrayList class is used for memory optimization. It trims the capacity of ArrayList to the current list size. This method is… [Read More]
Java ArrayList remove(Object obj) Method example
In this guide, you will learn how to remove a specified element from an ArrayList using remove() method. The method remove(Object obj) removes the first… [Read More]
Java ArrayList remove(int index) Method example
Method remove(int index) is used for removing an element of the specified index from a list. It removes an element and returns the same. It… [Read More]
Java ArrayList lastIndexOf(Object 0bj) Method example
The method lastIndexOf(Object obj) returns the index of last occurrence of the specified element in the ArrayList. It returns -1 if the specified element does… [Read More]
Java ArrayList isEmpty() Method example
The isEmpty() method of java.util.ArrayList class is used to check whether the list is empty or not. This method returns a boolean value. It returns true if… [Read More]
Java ArrayList ensureCapacity() Method example
ArrayList internally implements growable dynamic array which means it can increase and decrease its size automatically. If we try to add an element to a… [Read More]
Java ArrayList indexOf() Method example
Java.util.ArrayList class method indexOf(Object o) is used to find out the index of a particular element in a list. Method indexOf() Signature public int indexOf(Object… [Read More]
Java ArrayList get() Method example
ArrayList get(int index) method is used for fetching an element from the list. We need to specify the index while calling get method and it… [Read More]
Java ArrayList contains() Method example
ArrayList contains() method is used for checking the specified element existence in the given list. public boolean contains(Object element) It returns true if the specified… [Read More]
Java ArrayList addAll(int index, Collection c) Method example
In the last tutorial we have shared the example of addAll(Collection c) method which is used for adding all the elements of Collection c at the… [Read More]
Java ArrayList addAll(Collection c) Method example
In this tutorial we will see the usage of addAll() method of java.util.ArrayList class. This method is used for adding all the elements of a… [Read More]
Java ArrayList add(int index, E element) example
Simple add() method is used for adding an element at the end of the list however there is another variant of add method which is… [Read More]