How to find length/size of Arraylist in java

Previous
Next

In this tutorial, we will see how to find length/size of Arraylist in java.
You can use ArrayList’size() method to calculate size of ArrayList.
Let’s understand it with the help of Simple example.

When you run above program, you will get below output:

Size of Country List is: 4
[India, China, Bhutan, Nepal]
Size of Country List is: 2
[India, Bhutan]

As you can see here, size of ArrayList was 4, then we removed two elements from it and size of ArrayList became two.
That’s how you can find length/size of ArrayList in java.

Previous
Next

Join Our News Letter - Stay Updated

Subscribe to Awesome Java Content.

Add Comment

Join Our News Letter - Stay Updated

Subscribe to Awesome Java Content.
You can like our facebook page Java2blog