问题:我只想问2个问题,如果我在java中写下2个代码,那么哪个在cpu周期方面更快?为什么?有人告诉我,第一个选项在cpu周期方面是不正确的,因为检查了2个条件,即if和!
boolean flag = true;
//OPTION ONE
if(!flag) {
//error
} else {
//got the answer
}
//OPTION TWO
if(flag) {
//got the answer
} else {
//error
}
Run Code Online (Sandbox Code Playgroud) java ×1