I have this:
switch (account){
case 08120:
// Savings deposit interest rate
return null;
case 13100:
// Recei
It's not a java bug.
You cannot use the format of 0XXXXX for decimal numbers. Decimal numbers should be started with a non-zero digit.
Use 8120 instead of 08120
This is a little misleading/cryptic error message. In your code:
case 08120:
// Savings deposit interest rate
return null;
You have used 08120
, which is being interpreted as an octal literal instead of a decimal one. Since your next digit is 8
(not between 0 - 7
), it is an invalid/out-of-range octal literal and hence the compiler error.
First things first: it's unlikely you've stumbled across a Java bug. Blame your code first.
08120
is an octal literal in Java since it starts with a leading zero.
And 8 is not a valid octal digit (only 0 to 7 are).
Therefore you get a compilation error, albeit a little misleading.
Numbers starting with a 0
are interpreted as an octal number also 8 would not fit in there since the valid octal digits can be 0 through to 7. This is not a bug, try starting your number without the 0
.