I have an array with zero values, and I wish to copy this array to other array but without the zero values. How can I do this if determining the array size is not possible because I do not know how many zeros are there. Please note that I can not use List or ArrayList because of reasons.
// frame is the original array
final int[] sorted = new int[??];
for (int i = 0; i < frame.length; i++) {
if (frame[i] != 0) {
sorted[i] = frame[i];
}
}