I'm a newbie learning Java currently being introduces do the switch/case construct. The book I'm reading uses the following example:
int eingabe = 256;
final byte einKleinesByte = 2;
final char einKleinerCharacter = 'c';
final short einKleinesShort = 500;
switch(eingabe) {
case einKleinesByte:
case einKleinerCharacter:
case einKleinesShort:
The explanation is that these 3 constant are defined with the help of the keyword final, which is essential, because variables cannot be used for the cases.
My question is, what is the difference between final byte einKleinesByte = 2;
and byte EIN_KLEINES_BYTE = 2;
as they are both defined as constants?
Thanks for the help!