Collections

Java ArrayList length example

Java ArrayList length example shows how to get length of ArrayList. Example also shows how to get size or length of an ArrayList using size method.

How to get ArrayList length in Java?

To get length of ArrayList, use size method of ArrayList.

This method returns number of elements in the ArrayList.

Example

Output

You can use size method to get the number of elements contained in the ArrayList and loop through them as given below.

Output

Please let us know your views in the comments section below.

 

Want to learn quickly?
Try one of the many quizzes. I promise you will not be disappointed.

About the author

rahimv

rahimv

rahimv has over 15 years of experience in designing and developing Java applications. His areas of expertise are J2EE and eCommerce. If you like the website, follow him on Facebook, Twitter or Google Plus.

Add Comment

Your email address will not be published. Required fields are marked *