Array

Main.java
public class Main {
    public static void main(String[] args) {
        int[] myArray = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
        for(int i = 0; i <= 9; i++) {
            System.out.println(myArray[i]);
        }
    }
}

You can use int[] to define array type and use curly braces to assign values to it. You can use for loop function to print out the array values.

Last updated