是否可以以编程方式抛出 NullPointerException?[已关闭]
当存在后置条件时,方法的返回值不得为 null,该怎么办?
我可以做
assert returnValue != null : "Not acceptable null value";
但是断言可以关闭!
所以可以做吗
if(returnValue==null)
      {
           throw new NullPointerException("return value is null at method AAA");
      }
?
或者,对于这样的条件,使用用户定义的异常(如NullReturnValueException)更好?
 
					 
				 
				    		 
				    		 
				    		 
				    		