-4

I`ve two methods to discharge an ArrayList in java:

1- re-assign the list object.

list = new ArrayList();

2- using clear method.

list.clear();

Which is better?

Sayed
  • 255
  • 1
  • 3
  • 14

1 Answers1

1

If you have a large arraylist it may be faster to make a new arraylist than using clear. http://www.docjar.com/html/api/java/util/ArrayList.java.html

Scath
  • 3,777
  • 10
  • 29
  • 40