我正在使用Eclipse在Android中开发应用程序.我编写了以下代码,在测试中第一个和第三个" if "块无法访问.为什么?
当我向数字添加前导零时,等于运算符返回false.
int var = 123;
if (var == 0123) {
//not reachable
}
if (var == 123) {
//reachable
}
if (var == (int)0123) {
//not reachable
}
if (var == (int)123) {
//reachable
}
Run Code Online (Sandbox Code Playgroud)