Java Program to Get the Size of the LinkedList Collection

You are currently viewing Java Program to Get the Size of the LinkedList Collection

Java program to get the size of the LinkedList collection

// Java program to get the size of the 
// LinkedList collection

import java.util.LinkedList;

public class Main {
  public static void main(String[] args) {
    LinkedList list = new LinkedList();

    list.add(1);
    list.add("TWO");
    list.add(3);
    list.add("FOUR");
    list.add("TWO");
    list.add(true);
    list.add("THREE");

    System.out.println("Size of LinkedList: " + list.size());
  }
}

Output

Size of LinkedList: 7

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply