fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10.  
  11.  
  12. public static class PrintIt
  13. {
  14. static int[] numbers = new int[10];
  15. static int i = 0;
  16.  
  17. public static void PrintOrder()
  18. {
  19. System.out.println("\nList of numbers in order: \n");
  20. for (int i = 0; i < numbers.length; i++)
  21. {
  22. System.out.println(numbers[i]);
  23. }
  24. }
  25.  
  26. public static void PrintReverse()
  27. {
  28. System.out.println("\nList of numbers in reverse order: \n");
  29. for (int i = numbers.length - 1; i >= 0; i--)
  30. {
  31. System.out.println(numbers[i]);
  32. }
  33. }
  34. }
  35.  
  36.  
  37. public static void main (String[] args) throws java.lang.Exception
  38. {
  39.  
  40. Scanner input = new Scanner(System.in);
  41.  
  42. System.out.println("\nPlease input " + 10 + " numbers.");
  43.  
  44. for (int i=0; i < PrintIt.numbers.length; i++)
  45. {
  46. PrintIt.numbers[i] = input.nextInt();
  47. }
  48.  
  49. PrintIt.PrintOrder();
  50. PrintIt.PrintReverse();
  51.  
  52.  
  53. }
  54. }
Success #stdin #stdout 0.11s 380672KB
stdin
2 4 6 8 10 12 14 16 18 20
stdout
Please input 10 numbers.

List of numbers in order: 

2
4
6
8
10
12
14
16
18
20

List of numbers in reverse order: 

20
18
16
14
12
10
8
6
4
2