Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Application Reverse reads numbers into an array
- // and prints them out in reverse order.
- import java.util.Scanner;
- import java.io.*;
- public class Reverse
- {
- public static void main(String[] args) throws IOException
- {
- final int MAX = 10;
- Scanner inFile = new Scanner(new FileReader("Reverse.dat"));
- int[] numbers;
- numbers = new int[MAX];
- int value;
- int index;
- for (index = 0; index < numbers.length; index++)
- {
- numbers[index]=inFile.nextInt();
- }
- for (index = MAX - 1; index >= 0; index--)
- System.out.println(numbers[index]);
- inFile.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement