vendredi 11 novembre 2016

I want to print random numbers from -100 to 100

I want to print 10 random numbers from -100 to 100, but my code below always print negitive number. I did not get any answer for this. How to do this ?

import java.util.Random;
public class VectorAndList {
public static void main(String arg[]){
    Random random = new Random();
    int number ;
    for(int i=0;i<10;i++)
    System.out.println(number = random.nextInt(100)+ (-100)) ;
}
}




Aucun commentaire:

Enregistrer un commentaire