@ SuppressWarnings ( "unchecked" ) public static void setIndex ( Object array , int index , Object val ) throws ReflectError , UtilTargetError { try { val = Primitive . unwrap ( val ) ; if ( array instanceof List ) ( ( List < Object > ) array ) . set ( index , val ) ; else Array . set ( array , index , val ) ; } catch ( IllegalArgumentException e1 ) { // fabricated array store exception throw new UtilTargetError ( new ArrayStoreException ( e1 . getMessage ( ) ) ) ; } catch ( IndexOutOfBoundsException e1 ) { int len = array instanceof List ? ( ( List < ? > ) array ) . size ( ) : Array . getLength ( array ) ; throw new UtilTargetError ( "Index " + index + " out-of-bounds for length " + len , e1 ) ; } }
Set element value of array or list at index . Array . set for array or List . set for list .