How to initialize HashSet in java

We have many ways to initialize HashSet in java. HashSet can be initialized in one line, Using constructors, Using Arrays. 1. Initialize HashSet using Constructors

Read More →

How to convert ArrayList to HashSet

In this post we will see examples to convert ArrayList to HashSet in java. HashSet and ArrayList are both Collection objects. Hence we can pass ArrayList to the construtor of the HashSet and get it

Read More →

How to convert ArrayList to Array

In this post we will see examples on how to convert ArrayList to Array in java. To convert ArrayList to Array we will use the toArray method from ArrayList.

Example

Read More →

How to create Sublist from ArrayList

To create Sublist from ArrayList in java, we need to use the subList(int fromIndex,int toIndex) method provided by ArrayList. We will see the example on how to use the subList method. [crayon-68eb2

Read More →

ArrayList ensureCapacity example

If you have an ArrayList that already has lots of elements and you are trying to add more elements to the ArrayList, this may degrade the performance of the system. To improve the performance, you

Read More →