public class Test {
public static void main(String[] args)
{
Boolean b =null;
if(b == true){
System.out.println("wqw");
}else{
System.out.println("wqew");
}
}
抛出异常:
Exception in thread "main" java.lang.NullPointerException
at Test.main(Test.java:19)
实验表明 JAVA中 NULL不能用于 == 中,否则抛出空指针异常
补充:但是这样是可以的
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
Integer a = null;
if(a == null){
}
}
}
![难过](http://static.blog.csdn.net/xheditor/xheditor_emot/default/sad.gif)