![]() |
VOOZH | about |
In Java, the clear() is used to remove all the elements from a LinkedList. This method only clears all the element from the list and not deletes the list. After calling this method, the list will be empty.
void clear()
Example: Here, we use the clear() method to remove elements from the LinkedList.
Original LinkedList: [Geeks, for, Geeks] List after clearing all elements: []