lundi 7 septembre 2020

Java Random class execution for printing a six digit number only [duplicate]

I want to generate a six-digit random number everytime. I am using

public class Test {
    static Random rand = new Random();

    
    public static void main(String[] args) {

        int rand_int1 = rand.nextInt(1000000);
        System.out.println(rand_int1);

Will it print the six-digit number or it can print any number between 0 to 1000000. I executed and got a 6 digit number but just want to be sure Can it give 1 or 2 or 3 digit number also?




Aucun commentaire:

Enregistrer un commentaire