Programming Steps :
1. Create LinkedList having first node item 123.
LinkedList ll = new LinkedList();
ll.add("deepika");
ll.addFirst(123);//reserved seat
2. and add more item on this LinkedList.
ll.add(2,"Heera");
ll.add(1,"Tarun");
ll.addLast("Deepak")
3. Find the First element of LinkedList.
System.out.println("first element is "+ll.getFirst());Complete Program:
import java.util.LinkedList;
public class A
{
public static void main(String a[])
{
LinkedList ll = new LinkedList();
ll.add("deepika");
ll.addFirst(123);//reserved seat
ll.add(2,"Heera");
ll.add(1,"Tarun");
ll.addLast("Deepak");
System.out.println("ll is: "+ll);
System.out.println("first element of ll is "+ll.getFirst());
}
}