VOOZH about

URL: https://www.geeksforgeeks.org/java/abstractlist-clear-method-in-java-with-examples/

⇱ AbstractList clear() method in Java with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

AbstractList clear() method in Java with Examples

Last Updated : 22 Aug, 2019
The clear() method of java.util.AbstractList class is used to remove all of the elements from this list. The list will be empty after this call returns. Syntax:
public void clear()
Returns Value: This method does not return anything. Below are the examples to illustrate the clear() method. Example 1:
Output:
Original ArrayListlist : [A, B, C, D, E]
New ArrayList : []
Example 2:
Output:
Original ArrayListlist : [10, 20, 30, 40, 50]
New ArrayList : []
Comment