i saw this code somewhere
switch(greet){
case HELLO:
System.out.println("Formal Greeting");
break;
case HI:
System.out.println("Friendly Greeting");
break;
case YO:
System.out.println("Informal Greeting");
break;
default:
System.out.println("Person did not greet");
}
It did not mention the type of datatype of the greet variable against which the cases are being checked.. but it’s east to figure out that it’s neither a byte,nor is it a Short or Int So logically the last permissible data type left for the switch block to accept as a variable is the char data type but i believe that char only takes single values like ‘c’ or ‘3’ ..so how do such big values like hello get evaluated? what is the possible explanation?
My best guess is that this is an Enum, and hello is an enum constant declared on the Enum.
So basically what we have here is:
Enum docs