Caricamento...Random rand = new Random();
// Interi random
int i = rand.nextInt();
// Continua a chiamare nextInt() per generare continuamente nuovi numeri casuali
// Numeri casuali da 0 a 10
int n = 10;
i = rand.nextInt(n+1);
// Tipi primitivi
boolean b = rand.nextBoolean();
long l = rand.nextLong();
float f = rand.nextFloat(); // 0.0 <= f < 1.0
double d = rand.nextDouble(); // 0.0 <= d < 1.0
Lascia un commento
Copyright © 2005 - 2010 :: ianaz - created by Silvio Rainoldi