“整数太大”对于一个小的编译时间常数 [英] "Integer too large" for a small compile time constant

查看:124
本文介绍了“整数太大”对于一个小的编译时间常数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个:

switch (account){
    case 08120:
        // Savings deposit interest rate
        return null;                
    case 13100:
        // Receivables contractual interest
        return null;                
    case 16550:
       // Default management process accounts payable
       return null;                                
}

但编译器抱怨整数 08120 太大了!

But the compiler complains tha the integer 08120 is too large!

究竟发生了什么?

推荐答案

首先要做的事情是:不太可能你偶然发现了Java漏洞。首先归咎于你的代码。

First things first: it's unlikely you've stumbled across a Java bug. Blame your code first.

08120 是Java中的八进制文字,因为它启动前导零。

08120 is an octal literal in Java since it starts with a leading zero.

8不是有效的八进制数字(只有0到7)。

And 8 is not a valid octal digit (only 0 to 7 are).

因此,您会收到编译错误,尽管有点误导。

Therefore you get a compilation error, albeit a little misleading.

这篇关于“整数太大”对于一个小的编译时间常数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆