public static Object getIndex ( Object array , int index ) throws UtilTargetError { Interpreter . debug ( "getIndex: " , array , ", index=" , index ) ; try { if ( array instanceof List ) return ( ( List < ? > ) array ) . get ( index ) ; Object val = Array . get ( array , index ) ; return Primitive . wrap ( val , Types . arrayElementType ( array . getClass ( ) ) ) ; } 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 ) ; } }
Get object from array or list at index .