Empty an array in Java / processing

后端 未结 8 1373
醉梦人生
醉梦人生 2020-11-27 19:05

Other than looping through each element in an array and setting each one to null, is there a native function in Java / processing to simply empty an array (or destroy it, to

8条回答
  •  抹茶落季
    2020-11-27 19:17

    I just want to add something to Mark's comment. If you want to reuse array without additional allocation, just use it again and override existing values with new ones. It will work if you fill the array sequentially. In this case just remember the last initialized element and use array until this index. It is does not matter that there is some garbage in the end of the array.

提交回复
热议问题