As of java version 1.7, it is also possible to declare String type in switch statement.

in #java6 years ago (edited)

I did not know that it was possible to have a String type when declaring a switch statement. Since version 1.7, it was possible, but I realized that it could not be done by changing the character to Enum type and using the switch statement or the if else statement.

Starting with Java 1.7, it becomes available as follows. It's easy. Now I know.

switch (oMyGoodness) {
case "I am me": case "You are you":
result = 0; break;
case "I am you": case "You are me":
result = 1; break;
}

Coin Marketplace

STEEM 0.17
TRX 0.15
JST 0.028
BTC 58906.95
ETH 2310.92
USDT 1.00
SBD 2.46