samedi 4 juillet 2020

Using Random Class but my variable isn't random? [duplicate]

 for(int i = 0; i < emojiCnt; i++){

            Random rand = new Random(1000);
            int randNum = rand.nextInt((3) + 1);
            switch (randNum){
                case 1:
                    //Code
                case 2:
                    //Code
                case 3:
                    //Code
                default:
                    //Code
            }
            randNum = rand.nextInt((10) + 1);
        }

Every time I run the code, it gives the same result and is not random? I reassign randNum so that it will go to a random number but it doesn't seem to change?




Aucun commentaire:

Enregistrer un commentaire