With Java, I'm reading a book to re-cover the basics I forgot in college, and they're showing me a swtich statement like so:
void helpon(int what) {
switch(what) {
case '1': break;
case '2': break;
}
}
I omitted case code because irrelevant.
However, it seemed odd to me to use an int
and still wrap the case statements in single quotes, so I went to the oracle docs and found an example that was the same as the example above, but without the quotes.
Do quotes matter for a switch statement that uses integers as a case? Why would '1'
work, if what
is an int
and '1'
is a char?