Use ArrayUtils::isArrayIndexValid method in ArrayUtils::get. (#552)
This commit is contained in:
parent
553a3a75df
commit
496eb10372
|
@ -1679,13 +1679,7 @@ public class ArrayUtils {
|
|||
* @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…
Reference in New Issue