import java.util.LinkedList; LinkedListlistOfStrings = new LinkedList<>(); listOfStrings.add("apple"); listOfStrings.add("banana"); listOfStrings.add("cherry"); String firstString = listOfStrings.getFirst(); System.out.println(firstString); // Output: "apple"
import java.util.LinkedList; LinkedListPackage library: java.utillistOfIntegers = new LinkedList<>(); listOfIntegers.add(10); listOfIntegers.add(20); listOfIntegers.add(30); int firstInteger = listOfIntegers.getFirst(); System.out.println(firstInteger); // Output: 10