Java – Count the number of items in a List
In Java, we can use List.size()
to count the number of items in a List
package com.mkyong.example;
import java.util.Arrays;
import java.util.List;
public class JavaExample {
public static void main(String[] args) {
List<String> list = Arrays.asList("a", "b", "c");
System.out.println(list.size());
}
}
Output
3
References
About Author
Comments
Subscribe
0 Comments