Java examples for Language Basics:Array
Initializing the elements of an array with an array initializer.
public class Main { public static void main(String[] args) {/*from w w w.ja v a 2s . com*/ // initializer list specifies the initial value for each element int[] array = {132, 217, 614, 118, 915, 14, 910, 701, 60, 37}; System.out.printf("%s%8s%n", "Index", "Value"); // column headings // output each array element's value for (int counter = 0; counter < array.length; counter++) System.out.printf("%5d%8d%n", counter, array[counter]); } }