Hi all, I am learning Java, and last night I was writing a Java program to insert elements into the linked list at the first and the last position. Here is my code
While I compile the code I show and error, can any one please help me in this? Code reference here
Java:
import java.util.LinkedList;
public class program {
public static void main(String[] args) {
// create an empty linked list
LinkedList<String> list = new LinkedList<String>();
// use add() method to add values in the linked list
list.add("Red");
list.add("Green");
list.add("Black");
System.out.println("Original linked list:" + list);
// Add an element at the beginning
l_list.addFirst("White");
// Add an element at the end of the list
l_list.addLast("Pink");
System.out.println("Final linked list:" + list);
}
}
While I compile the code I show and error, can any one please help me in this? Code reference here