The javadoc of ArrayUtils.isNotEmpty()
in Apache Commons Lang seems to be wrong. Or, at least, misleading. It says
Returns: true if the array is not empty or not null
In my understanding, an empty array is not null
. So, according to the above definition, isNotEmpty()
should return true
for an empty array, which is counterintuitive.
Wouldn't
Returns: true if the array is not null and not empty
be more correct?
Deprecated. this method has been superseded by insert(int, boolean[], boolean...) and may be removed in a future release.
The Arrays class in java. util package is a part of the Java Collection Framework. This class provides static methods to dynamically create and access Java arrays. It consists of only static methods and the methods of Object class. The methods of this class can be used by the class name itself.
Wouldn't
Returns: true if the array is not null and not empty
be more correct?
Yes you are right. The doc is a bit misleading. In fact, if you see the source code, it does exactly that:
public static boolean isNotEmpty(Object[] array) {
return (array != null && array.length != 0);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With