Java switch statement - TechRepublic
General discussion
March 15, 2001 at 10:17 AM
m.r.chambers

Java switch statement

by m.r.chambers . Updated 25 years, 3 months ago

Is it possible to use relational operators in the case: section of a Java switch
eg
switch (guess)
case (>number):…
etc

I know the above doesn’t work, but that’s the sort of thing I need. I need to compare the variable in the switch (guess) with a computer generated random number, and report whether the guess is too high, too low, or correct (it’s a simple guessing game…pick a number between 1 and 1000 etc).

Thanks,
M.R.Chambers

This discussion is locked

All Comments