dimanche 1 mai 2022

How to generate and save random number in java? [closed]

I need randomly generated number to be saved, to use it as a pin code

I have separate method for generating random 5 digit pin

private static int getPin{
    Random random = new Random;
    int n = random.nextInt(100000);
    return n;
}

Integer n that was generated in method is than printed out

Client should write this number and be able to enter the project

But for some reason number n constantly changes, and so it is impossible for Client to know the pin code

How to save number n, so it would not change and could be used in different parts of my code




Aucun commentaire:

Enregistrer un commentaire