Java tutorial
import java.lang.reflect.Array; public class MainClass { public static void main(String args[]) { Object array = Array.newInstance(int.class, 3); int length = Array.getLength(array); for (int i = 0; i < length; i++) { int value = i; Array.setInt(array, i, value); } for (int i : (int[]) array) { System.out.println(i); } } }