I want to copy a larger array that some elements randomly removed by remove() method into the a small array.
I have used System.arraycopy() but this method copies elements respectively. Therefore some elements in the larger array don't be copied.
I want to copy the larger array's all non-removed elements into small array which has the length is equal to number of non-removed elements in larger array.
ArrayListinstead of array, it shrinks when elements are temoved, and you will end up with a smallerArrayList. Another idea, make a stream, filter out removed elements and collect the remainig elements into a new array.