简体   繁体   English

JAVA 中的意外行为

[英]Unexpected behavior in JAVA

在此处输入图片说明

I can't understand this!!我无法理解这个!! Please help请帮忙

for (int i = fromSuraIndex; i <= toSuraIndex; i++) {
        if (i == toSuraIndex && toCharIndex == 0) {
            break;
        }
        if (i > fromSuraIndex) {
            currentWordIndexInSura = 0;
            suraGenaricWordIndexMap.put(fromSuraIndex,currentWordIndexInSura - words.size());
        }
}

The problem occurs in the first loop , while "fromSuraIndex" equal "i" equal 1, Why the debugger enter the IF block问题出现在第一个循环中,而“fromSuraIndex”等于“i”等于1,为什么调试器进入IF块

This means that it won't enter to if block that you showed only for the first step of the loop where 'i' will have its initial value which is 'fromSuraIndex'.这意味着它不会进入您仅在循环的第一步中显示的 if 块,其中“i”的初始值为“fromSuraIndex”。 When 'i' value is incremented then it qualifies the if statement.当“i”值增加时,它限定了 if 语句。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM