I am learning Java, at a very beginning level. I am trying to print the Dice result, so from 1 to 6.
//instance of random class
Random DICE = new Random();
int DiceRange = 7;
int RIGHT = DICE.nextInt(DiceRange);
int LEFT = DICE.nextInt(DiceRange);
System.out.println("Right Dice = " + RIGHT);
System.out.println("Left Dice = " + LEFT);
The issue with this code that "Zero" is also printed sometimes. I want to keep the range from 1 to 6, instead of 0 to 6. I tried to do the following, but did not work:
int i = 0;
while (DiceRange == 0); {
i++;
}
The CPU went to 100% :)
So how to exclude zero from this?