0

Okay, so I want to use this random number generator to output one case, instead it spits out all of them, what am I doing wrong?

SecureRandom goodNumber = new SecureRandom();
int good = 1+ goodNumber.nextInt(4);

switch(good){
    case 1:
            System.out.println("Test1");
    case 2:
            System.out.println("Test2");
    case 3:
            System.out.println("Test3");
    case 4:
            System.out.println("Test4");

}
System.out.println(good);
}
}

Now the output might look like:

Test2

Test3

Test4

2

And instead, I just want it to randomly output one string

Forrest
  • 157
  • 14

0 Answers0