问题 今天出了个bug 由于用max()函数的时候返回了一个null select max(age) from student where name like "wang"; 若没有满足条件的返回,那么该语句会返回null,从而导致空指针异常。 如下的查询不会返回null,若没有满足条件的数据,那么会返回0. select count(0) from student where name like "xuan"; 总结 空指针异常算是开发中最常见的异常之一。 所以,避免控制正异常也是开发人员的一个基本素养。 我会继续将开发中容易产生空指针异常的情形在本文追加。