简体   繁体   中英

Eclipse flags a piece of code with a 'Dead code' warning. Why in this case?

I know that there are a few examples of 'random dead code warning' in Eclipse.

But specifically for my case, I want to find out whether this is also a 'false positive' or whether I am too tired to understand what is going on...

    @Override
    public int getNumUnappendedCol() {

        return appendIndex == -1 ? getNumCol() : appendIndex; 
    }

This ternary statement is being flagged, specifically the condition and appendIndex . As I understand it (not my code), this is supposed to return appendIndex if it is not equal to -1. Otherwise return the value obtained from getNumCol() .

Am I missing something or should I just ignore Eclipse? I regularly refresh/ clean/ build the project so that wouldn't solve the issue.

问题最终导致了将appendIndexfinal声明初始化为-1,因此三元语句甚至都无法访问false选项。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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