提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
创建int数组并分配值
public class ArrayDemo {//from 时代Java - nowjava.com public static void main(String[] args) { int[] anArray; // declare an array of integers anArray = new int[10]; // create an array of integers // assign a value to each array element and print for (int i = 0; i < anArray.length; i++) { anArray[i] = i; System.out.print(anArray[i] + " "); } System.out.println(); } }