Java Program to Create a Simple Linked List Using LinkedList Collection Class

You are currently viewing Java Program to Create a Simple Linked List Using LinkedList Collection Class

Java program to create a simple linked list using LinkedList collection class

// Java program to create a simple Linked-List 
// using LinkedList collection class

import java.util.LinkedList;
public class Main {
  public static void main(String[] args) {
    LinkedList < String > countries = new LinkedList < String > ();

    countries.add("India");
    countries.add("USA");
    countries.add("UK");
    countries.add("CANADA");

    System.out.println(countries);
  }
}

Output

[India, USA, UK, CANADA]

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