关于什么时候使用前置的判断
String str = xxx;
if("xxx".equal(str)) {
xxx;
}
这样写可以省去str的判空过程
String str = xxx;
if(str != null && str.equal("xxx")) {
xxx;
}
其它场景还是使用后置好,因为代码的可读性还是非常重要的。
String str = xxx;
if("xxx".equal(str)) {
xxx;
}
这样写可以省去str的判空过程
String str = xxx;
if(str != null && str.equal("xxx")) {
xxx;
}
其它场景还是使用后置好,因为代码的可读性还是非常重要的。