When you were doing this for
Netbeans showed that bulb tips to improve the code in the for
line. The suggestion was to reverse the condition. Here is the code:
Before improvement:
for(int j = 0; j < selectionPaths.length; j++) {
if( isDescendant(selectionPaths[j], path) )
return true;
}
After of the improvement suggested by Netbeans:
for(int j = 0; selectionPaths.length >= j; j++) {
if( isDescendant(selectionPaths[j], path) )
return true;
}
Update: After the "improvement" the program throws the ArrayIndexOutOfBoundsException
exception.
But then why did Netbeans give this suggestion if after accepting it the program gives error? Is there a specific reason or only issue of code convention? Or is it a Netbeans fault?
Note: The Netbeans version is 8.0.1. The suggestion appears when the cursor is positioned in the condition, more precisely in the variable selectionPaths
.