Accept array and print its elements in reverse order in java

Write a java program read in an array of integer and print its elements in reverse order.

package array;

import java.util.*;
public class array2 
{
    public static void main(String args[])
    {
        Scanner s=new Scanner(System.in);
        int a[]=new int[10];
        int i;
        System.out.println("enter the elements::");
        for(i=0;i<10;i++)
        {
            a[i]=s.nextInt();
                    
        }
        for(i=9;i>=0;i--)
        {
            System.out.println("the elements are::"+a[i]);
        }
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *