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