correct my code please.
I`m need to create new array without minimum vulue.
I`m need to create new array without minimum vulue.
Java:
public class ArT {
public static void main(String[] args) {
int min;
int[] arrayA;
int size;
int newSize;
int counter;
min = 50;
arrayA = new Random().ints(50, 0, 50).toArray();
size = arrayA.length;
counter = 0;
System.out.println("my array: " + Arrays.toString(arrayA));
for (int i : arrayA) {
if (i <= min) {
min = i;
}
}
System.out.println("min: " + min);
for (int i : arrayA) {
if (min == i) {
counter++;
}
}
System.out.println("min counter: " + counter);
newSize = size - counter;
int[] arrayB;
arrayB = new int[newSize];
for (int j = 0; j < arrayA.length; j++) {
for (int k = 0; k < arrayB.length; k++) {
if (arrayA[j] != min) {
arrayB[k] = arrayA[j];
} else {
j++;
}
}
}
System.out.println("new array: " + Arrays.toString(arrayB));
}
}