Java - Output array backwards one by one

Description

Output array backwards one by one

Demo

import java.io.IOException;
import java.util.Scanner;

public class ReverseNumbers {

  public static void main(String args[]) throws IOException {
    int array[] = new int[10];

    System.out.println("Enter 10 numbers:");
    Scanner scanner = new Scanner(System.in);

    for (int i = 0; i < array.length; i++) {
      array[i] = scanner.nextInt();/*w  ww  . j a  va  2s .  c  o m*/
    }
    scanner.close();

    System.out.println("Reverse order:");
    System.out.println(array[9]);
    System.out.println(array[8]);
    System.out.println(array[7]);
    System.out.println(array[6]);
    System.out.println(array[5]);
    System.out.println(array[4]);
    System.out.println(array[3]);
    System.out.println(array[2]);
    System.out.println(array[1]);
    System.out.println(array[0]);
  }
}

Related Topic