why there is no isNull method in java object class

I wonder why there is no common method to check for null value at java object level. What is the problem if the java.lang.Object class have had a method isNull to check for null value.


没有理由这样做,你检查null作为oleksii声明...

if (foo == null) {

}

It is a sensible question as @jsn notes, but in the Java World the idea of an isNull is like an isTrue method. Just because Microsoft does it, doesn't make it a good idea. ;)

isNull can only return false as you can only call a method on a non-null reference. So if you can call isNull it must be false.


An isNull method would make no sense, as you need to call it on an object. But if you dont have an object (because it's null ), you can't call it on it.

链接地址: http://www.djcxy.com/p/76160.html

上一篇: 评估以字符串形式给出的数学表达式

下一篇: 为什么java对象类中没有isNull方法