java.util.LinkedList is a class in the Java programming language that implements the List interface using a doubly-linked list. This class provides a linked list implementation of the List and Deque interfaces. LinkedList allows for the insertion, deletion and retrieval of elements in constant time.
Example 1: Clear LinkedList
To clear a LinkedList, we can use the clear() method. This method deletes all the elements from the list, leaving an empty list.
LinkedList linkedList = new LinkedList<>(); linkedList.add("one"); linkedList.add("two"); linkedList.add("three");
The LinkedList class is part of the java.util package library.
Java LinkedList.clear - 30 examples found. These are the top rated real world Java examples of java.util.LinkedList.clear extracted from open source projects. You can rate examples to help us improve the quality of examples.