Online Java Compiler By
JavaTpoint.com
import java.util.LinkedList; import java.util.List; public class JavaListSizeExample1 { public static void main(String[] args) { List
list= new LinkedList<>(); list.add(34); list.add(56); list.add(12); list.add(43); System.out.println("List : "+list); //it will return the total size of the list int size= list.size(); System.out.println("Total element of the list : "+size); } }
Output