You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2004/02/02 11:16:13 UTC
DO NOT REPLY [Bug 26594] New: -
[lang] add getLength() method to ArrayUtils
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26594>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26594
[lang] add getLength() method to ArrayUtils
Summary: [lang] add getLength() method to ArrayUtils
Product: Commons
Version: unspecified
Platform: Other
OS/Version: Other
Status: NEW
Severity: Enhancement
Priority: Other
Component: Lang
AssignedTo: commons-dev@jakarta.apache.org
ReportedBy: Maarten.Coene@qmedit.com
Hi,
I need a method to determine the length of an array which doesn't throw a NPE if
the array is null (this makes the java.lang.reflect.Array.getLength() method
unsuitable for me because it throws a NPE if array is null).
Here is a possible implementation for an Object array:
public static int getLength(final Object[] array) {
if (array == null) {
return 0;
} else {
return array.length;
}
}
or, maybe you can use Object which makes this method usable for primitive arrays
as well:
public static int getLength(final Object array) {
if (array == null) {
return 0;
} else {
return java.lang.reflect.Array.getLength(array);
}
}
Can someone please add such a method ?
thanks,
Maarten
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org