小编Pra*_*eep的帖子

根据cpu周期JAVA重构代码

问题:我只想问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

-2
推荐指数
1
解决办法
113
查看次数

标签 统计

java ×1