英文:
In what version of Java did assigning false to an integer become invalid?
问题
我有以下来自一个看起来是 Java 1.1 库的遗留代码:
int colon_index = false;
for(int i = 0; i < params_split.length; ++i) {
int colon_index = params_split[i].indexOf(":");
if (colon_index > 0) {
// ...
}
}
它似乎将 false
赋值给了一个类型为 int
的变量。这是反编译的代码,因此 IntelliJ 反编译器也有可能出错。
我已经查阅了旧版本的发布说明,但还没有找到这个更改。
假设在 Java 的某个历史版本中这是正确的,在哪个版本的 Java 中停止支持这种语法?
英文:
I have the following legacy code from what looks to be a Java 1.1 library:
int colon_index = false;
for(int i = 0; i < params_split.length; ++i) {
int colon_index = params_split[i].indexOf(":");
if (colon_index > 0) {
// ...
}
}
It appears to be assigning false
to a variable of type int
. This is decompiled code, so it's also possible the IntelliJ decompiler has made a mistake.
I've checked release notes for old versions, but haven't been able to spot this change yet.
Assuming this was correct at some point in Java's history, in what version of Java did this syntax stop being valid?
答案1
得分: 0
你不能相信反编译的代码。最初,它应该是int colon_index = 0
。
查看这个答案以获取更多详情。
英文:
You can't trust decompiled code. Originally, it would've been int colon_index = 0
Check out this answer for more details.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论