VOOZH about

URL: https://www.geeksforgeeks.org/java/list-size-method-in-java-with-examples/

⇱ List size() method in Java with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

List size() method in Java with Examples

Last Updated : 11 Jul, 2025

The size() method of the List interface in Java is used to get the number of elements in this list. That is, the list size() method returns the count of elements present in this list container.

Example:


Output
Size : 0


Syntax of Method

public int size()

Parameters: This method does not take any parameters.

Return Value: This method returns the number of elements in this list.


👁 list size method in java


Example of using List size() Method

Example 1:


Output
Size : 5

Example 2:


Output
Size : 3
Comment