VOOZH about

URL: https://www.geeksforgeeks.org/java/arraydeque-clear-method-in-java/

⇱ ArrayDeque clear() Method in Java - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

ArrayDeque clear() Method in Java

Last Updated : 10 Dec, 2018
The Java.util.ArrayDeque.clear() method in Java is used to remove all of the elements from the Deque. Using the clear() method only clears all the element from the deque and does not delete the deque. In other words, it can be said that the clear() method is used to only empty an existing ArrayDeque. Syntax:
Array_Deque.clear()
Parameters: The method does not take any parameter. Return Value: The function does not return any value. Below programs illustrate the Java.util.ArrayDeque.clear() method: Program 1:
Output:
ArrayDeque: [Welcome, To, Geeks, 4, Geeks]
ArrayDeque: []
Program 2:
Output:
ArrayDeque: [10, 15, 30, 20, 5]
ArrayDeque: []
Comment