---
title: "null = userId与userId = null"
author: "higher141125"
date: "2013-07-28T11:56:33Z"
tags: []
categories: ["互联网"]
slug: "null-userid-userid-null"
draft: false
lastmod: "2013-07-28T11:56:33Z"
id: 1914540
url: "https://higher141125.iteye.com/blog/1914540"
---

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

如果你不小心写成了

userId = null

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

但是要是写成了

null = userId

报错的时候立即定位到这

 

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

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