Java: Array

This entry is part 10 of 54 in the series Learn Java

In declaring an array, the values can be assigned all at once by using a curly bracket notation.

Once the array elements are initialized, they can be accessed by referencing the elements’ indexes inside the square brackets.

Notice that index starts with 0.

package javaapplication10;

public class JavaApplication10 {

    public static void main(String[] args) {
        int[] a = {1,2,3};
        System.out.print(a[0] + a[1] + a[2] + "\n");





Series Navigation<< Java: For loop
Java: For each loop >>