List.size() has the following syntax.
int size()
In the following code shows how to use List.size() method.
import java.util.ArrayList; import java.util.List; // ww w. j a va 2 s. co m public class Main { public static void main(String[] args) { List list = new ArrayList(); list.add("1"); list.add("2"); list.add("3"); list.add("java2s.com"); System.out.println("List has:" + list.size()); } }
The code above generates the following result.