Question #289799

Write an application that stores 12 integers in an array. Display the ingeter from first to last, and then display the integers from last to first.

Expert's answer

public class Main {
    public static void main(String[] args) {
        int[] array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");
        }
        System.out.println();
        for (int i = array.length - 1; i >= 0; i--) {
            System.out.print(array[i] + " ");
        }
        System.out.println();
    }
}
LATEST TUTORIALS
APPROVED BY CLIENTS