print an array in reverse order java code example

Example 1: how to print array backwards

var array = ['a','b','c','d','e','f','g']
var j = array.length 

for(var i = 0; i < array.length ; i++){
    console.log(array[j])
    j=j-1 }

    /*

var j holds value of the array's number of values so every time in the loop it decrements by 1 making the 
function print a backwars array



    */

Example 2: reverse array java

// reverse array

for(int i=intArray.length-1;i>=0;i--)
         System.out.print(intArray[i] + "  ");

Tags:

Java Example