
没有不同。
第二个原因仅仅是因为C / C ++程序员总是执行分配而不是比较。
例如
// no compiler complaint at all for C/C++// while in Java, this is illegal.if(a = 2) {}// this is illegal in C/C++// and thus become best practice, from C/C++ which is not applicable to Java at all.if(2 = a) {}而java编译器会生成编译错误。
因此,由于可读性强,我个人更喜欢第一个,人们倾向于从左到右阅读,
if test is not equal to null而不是
null is notequal to test。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)