Apache Commons Lang 中ArrayUtils.isNotEmpty()
的javadoc 似乎是错误的。或者,至少,误导。它说
Returns: true if the array is not empty or not null
在我看来,空数组不是null
。所以,根据上面的定义,isNotEmpty()
应该为空数组返回 true
,这是违反直觉的。
不会
Returns: true if the array is not null and not empty
更正确吗?
最佳答案
Wouldn't
Returns: true if the array is not null and not empty
更正确吗?
是的,你是对的。该文档有点误导。事实上,如果您查看源代码,它就是这样做的:
public static boolean isNotEmpty(Object[] array) {
return (array != null && array.length != 0);
}
关于ArrayUtils.isNotEmpty 的 Javadoc 有问题吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21254161/