I have to make two new arrays from this existing one, one will have positive values, and one negative, not including 0. If this logic is right, I only have one problem, declaring the length of these two, new arrays. I'm a beginner in programming.
public static void main(String[] args) {
int[] array = {12, 23, -22, 0, 43, 545, -4, -55, 43, 12, 0, -999, -87};
int[] array1 = new int [];
int[] array2 = new int [];
for(int i=0; i<array.length; i++) {
if(array[i]>0) {
if(array[i]==0)
continue;
int[] array1 = new int[];
array1[i]=array[i];
} else if(array[i]<0) {
if(array[i]==0)
continue;
array2[i]=array[i];
}
}
if(array[i]==0)inside theif(array[i]>0)block, makes no sense.arrayand count how many positives and negatives elements are. Then, instantiatearray1andarray2with the given size