Java Reflection - Java Array.setShort(Object array, int index, short s)








Syntax

Array.setShort(Object array, int index, short s) has the following syntax.

public static void setShort(Object array,  int index,  short s)   throws IllegalArgumentException ,    ArrayIndexOutOfBoundsException

Example

In the following code shows how to use Array.setShort(Object array, int index, short s) method.

import java.lang.reflect.Array;
import java.util.Arrays;
//from  www. j  a v  a 2s . c  o m
public class Main {
  public static void main (String args[]) {
    short[] array = new short[]{1,2,3};
    
    Array.setShort(array, 1, (short)9);
    
    System.out.println(Arrays.toString(array));


  }
}

The code above generates the following result.