title: How can I print an array in reverse?
body: <p>This is my array code and I need to print it in reverse.</p>
  
  <pre><code>public class Array1D {
      public static void main(String[] args) {
          int[] array = new int[3];
          array[0] = 1;
          array[1] = 2;
          array[2] = 5;
          for (int i = 0; i &lt; array.length; i++) { //loop
              System.out.print("array["+i+"]=");
              System.out.println(array[i] + "   ");
          }
          System.out.println("the last element in the matrix = " + array[array.length - 1]); // finding the last element in the array
          System.out.println("   ");
      }
  }
  </code></pre>