The add() method of Java ArrayList class is used to add elements to an ArrayList. In this guide, we will see various examples of add… [Read More]
How to compare two ArrayList in Java
In this tutorial we will learn how to compare two ArrayList. We would be using contains() method for comparing two elements of different ArrayList. public… [Read More]
How to override toString method for ArrayList in Java
When we are dealing with ArrayList of Objects then it is must to Override the toString() method in order to get the output in desired… [Read More]
How to serialize ArrayList in java
ArrayList is serializable by default. This means you need not to implement Serializable interface explicitly in order to serialize an ArrayList. In this tutorial we will learn how… [Read More]
Difference between ArrayList and HashMap in Java
ArrayList and HashMap are two commonly used collection classes in Java. Even though both are the part of collection framework, the way they store and… [Read More]
How to join/combine two ArrayLists in java
In this tutorial we will see how to join (or Combine) two ArrayLists in Java. We will be using addAll() method to add both the… [Read More]
How to find length of ArrayList in Java
You can find the length (or size) of an ArrayList in Java using size() method. The size() method returns the number of elements present in… [Read More]
How to empty an ArrayList in Java
There are two ways to empty an ArrayList – By using ArrayList.clear() method or with the help of ArrayList.removeAll() method. Although both methods do the same… [Read More]
How to synchronize ArrayList in java with example
We have already discussed a bit about synchronization when we shared the tutorial on Vector vs ArrayList. As we are aware that ArrayList is non-synchronized… [Read More]
How to swap two elements in an ArrayList
This tutorial will help you understand how to swap two elements in an ArrayList. We are using Collections.swap() method for swapping. public static void swap(List… [Read More]