java.util.scanner - Need to subtract one from user input. How? Java -
basically need know how subtract 1 user input. trying x , y coordinate user place 2d array can 20x20, if user puts in 20, need program read 19 not out of bounds.
x = keyboard.nextint()
is have now.
// solution 1 x = math.min(19, math.max(0, keyboard.nextint() - 1)); // solution 2 x = keybord.nextint() - 1; if(x < 0) { // error?! x = 0; } else if(x > 19) { // error?! x = 19 }
Comments
Post a Comment