Home » Java List size() Method with Examples

Java List size() Method with Examples

by Online Tutorials Library

Java List size() Method

The size() method of List Interface returns the total number of elements present in this list.

Syntax

Parameters

NA

Return

The size() method returns the number of elements in this list.

Example 1

Test it Now

Output:

List : [34, 56, 12, 43]  Total element of the list : 4  

Example 2

Test it Now

Output:

Total students : 3   Name : Reema       School : Gita Convent School   Name : Geetu       School : Gita Convent School   Name : Saloni       School : Eicher School  

Example 3

Test it Now

Output:

Total alphabets : 26  List : [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z]  
Next TopicJava List

You may also like