java - Shrinking an ArrayList to a new size -


Do I really need to apply it myself?

  Private Wide Sequence List (Arrayist & lt; result & gt; list, int nuances) {for -i) list.remove (i); }  

Create a range of elements that you want to delete and then return the call The list given

  list.subList (23, 45). Clear ()  

This approach is described as a idiom in the document for both.


Here is a complete test code example of the unit!

  // Limit your tens of thousands of items to int k = yourHappyList.size (); If (k & gt; 10) yourHappyList.subList (10, k) clear (); / / So, k-1  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -