mirror of
https://github.com/apache/commons-lang.git
synced 2025-02-09 19:45:01 +00:00
Use ArrayUtils::isArrayIndexValid method in ArrayUtils::get. (#552)
This commit is contained in:
parent
553a3a75df
commit
496eb10372
@ -1679,13 +1679,7 @@ public static <T> T get(final T[] array, final int index) {
|
||||
* @since 3.11
|
||||
*/
|
||||
public static <T> T get(final T[] array, final int index, final T defaultValue) {
|
||||
if (array == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (index >= 0 && index < array.length) {
|
||||
return array[index];
|
||||
}
|
||||
return defaultValue;
|
||||
return isArrayIndexValid(array, index) ? array[index] : defaultValue;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user