Java Reflection - Java Array.setBoolean(Object array, int index, boolean z)








Syntax

Array.setBoolean(Object array, int index, boolean z) has the following syntax.

public static void setBoolean(Object array,  
                                          int index,  
                                          boolean z)   
            throws IllegalArgumentException,    
                   ArrayIndexOutOfBoundsException

Example

In the following code shows how to use Array.setBoolean(Object array, int index, boolean z) method.

/*from ww w  . j av a2s. c o m*/
import java.lang.reflect.Array;
import java.util.Arrays;

public class Main {
  public static void main (String args[]) {
    boolean[] array = new boolean[]{true,true,true};
    
    Array.setBoolean(array, 1, false);
    
    System.out.println(Arrays.toString(array));


  }
}

The code above generates the following result.