Kun*_*Lun 0 java intellij-idea
I have this code:
private boolean changeNcheckIP() {
//try 3 times before false
for(int i = 0; i < 3; i++) {
if(changeIP() && checkIP()) { return true; }
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
Intellij give me an warning at changeNcheckIP():
Boolean method changeNcheckIP() is always inverted
How can I fix that?
It is a warning, not an error (you are not obligated to fix it).
IntelliJ is just notifying you that you are always using your method changeNcheckIP() return as inverted.
Meaning that when you are calling the method (so far in your code) you are probably doing something like:
if(!changeNcheckIP()) {
//do something...
}
Run Code Online (Sandbox Code Playgroud)
Notice the ! in if loop, thats what IntelliJ is trying to tell you to "fix".
If you would use:
if(changeNcheckIP()) {
//do something...
}
Run Code Online (Sandbox Code Playgroud)
Warning will disappear (notice the removed "!" ), but you need to INVERT your return value so your IF logic will work properly.
| 归档时间: |
|
| 查看次数: |
518 次 |
| 最近记录: |