import java.util.LinkedList; public class Main { public static void main(String[] args) { LinkedList cars = new LinkedList(); cars.add("Volvo"); cars.add("BMW"); cars.add("Ford"); cars.add("Mazda"); System.out.println(cars); // Use get() to get the value of an item System.out.println(cars.get(0)); // Use set() to set the value of an item cars.set(0, "Opel"); System.out.println(cars); // Use remove() to remove an item cars.remove(0); System.out.println(cars); // Use addFirst() to add the item to the start cars.addFirst("Mazda"); System.out.println(cars); // Use addLast() to add the item to the end cars.addLast("Mazda"); System.out.println(cars); // Use removeFirst() remove the first item cars.removeFirst(); System.out.println(cars); // Use removeLast() remove the last item cars.removeLast(); System.out.println(cars); // Use getFirst() to display the first item in the list System.out.println(cars.getFirst()); // Use getLast() to display the last item in the list System.out.println(cars.getLast()); // Use clear() to clear the list cars.clear(); System.out.println(cars); } }