Java Reflection Java Java API
Class:
java.lang.reflect.Array
Method:
public static void setBoolean(Object array,
int index,
boolean z)
throws IllegalArgumentException,
ArrayIndexOutOfBoundsException
Sets the value of the indexed component of the specified array object to the specified
boolean
value.
Examples
package com.logicbig.example.array;
import java.lang.reflect.Array; import java.util.Arrays;
public class SetBooleanExample {
public static void main(String... args) { Object o = Array.newInstance(boolean.class, 3); for (int i = 0; i < 3; i++) { Array.setBoolean(o, i, true); } System.out.println(Arrays.toString((boolean[]) o)); } }
Output[true, true, true]
|
|