ITeye博客

null = userId与userId = null

higher141125 · 2013-07-28 11:56 · JAVA-EE · 互联网 · Markdown

http://zhidao.baidu.com/question/130229186.html

如果你不小心写成了

userId = null

报错的时候一般不会报这里,因为赋值又没有错。

但是要是写成了

null = userId

报错的时候立即定位到这

 

 还有一种情况,比如a是一个String变量,要比较a是否等于"hello"就要这样写:

 "hello".equals(a),不要a.equals("hello"),后面一种容易空指针异常,前面没有

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。