Why does this code print only one value? I expected it to be random.
import java.util.Random;
public class abcd {
public static void main(String[] args){
int küme[] = new int[20]; //creation of array
for(int i=0; i<20; i++){
int number=(int) Math.random()*6; // creation of random numbers between 0 and 5
küme[i] = number; // assignment of random numbers
System.out.print(" "+küme[i]);
}
}
}
Aucun commentaire:
Enregistrer un commentaire