1

Which is the best practice between

  • ArrayList.clear();
  • new ArrayList<Object>();

I have a list which gets data, I use them and then I have to recycle it. Which is the best way?

sirdan
  • 1,018
  • 2
  • 13
  • 34

1 Answers1

2

I think if u just clear it its 1 less object for GC to handle, so its better.

I dont see any actual advantage on creating a new array list object if not changing the type.

Gabriel Slomka
  • 1,487
  • 1
  • 11
  • 24