“Integer too large” for a small compile time constant

后端 未结 4 1474
深忆病人
深忆病人 2020-12-22 03:04

I have this:

switch (account){
    case 08120:
        // Savings deposit interest rate
        return null;                
    case 13100:
        // Recei         


        
4条回答
  •  渐次进展
    2020-12-22 03:43

    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.

提交回复
热议问题