I made this array but im struggling with counting the numbers. I could do it by using "IF" 10 times but it just seems wrong to me. Perhaps loop "for" would be the best to use here but i have no idea how to approach this.
import java.util.Random;
public class zadanie2 {
public static void main(String[] args) {
int array[];
array = new int[20];
for (int i = 0; i < array.length; i++) {
Random rd = new Random();
array[i] = rd.nextInt(10);
System.out.print(array[i] + ",");
}
}
}
Aucun commentaire:
Enregistrer un commentaire