Preview:
import java.util.*;
public class LinkedListDemo
{
public static void main(String[] args)
{
LinkedList<String> ll = new LinkedList<>();
ll.add("first"); ll.add("second"); ll.add("fourth");
System.out.println("Contents: " + ll);
System.out.println();
ll.add(2, "third"); ll.addFirst("zero");
System.out.println("Contents: " + ll);
System.out.println();
// experiment with more methods here and extend the program
}
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter