Reverse Array Program in Java
import java.util.*;
public class Reverse Array
{
public static void main(String[] args)
{
int ar[] = new int[10];
Scanner sc = new Scanner(System.in);
for (int i = 0; i < 10; i++)
{
System.out.print("Enter the number ar[" + i + "]:");
ar[i] = sc.nextInt();
}
System.out.println("Reverse Array are:");
for (int i = 9; i > 0; i--)
{
System.out.println("ar[" + i + "]:" + ar[i]);
}
}
}
Output:
Enter the number ar[0]:1 Enter the number ar[1]:5 Enter the number ar[2]:6 Enter the number ar[3]:4 Enter the number ar[4]:10 Enter the number ar[5]:25 Enter the number ar[6]:36 Enter the number ar[7]:41 Enter the number ar[8]:10 Enter the number ar[9]:78 Reverse Array are: ar[9]:78 ar[8]:10 ar[7]:41 ar[6]:36 ar[5]:25 ar[4]:10 ar[3]:4 ar[2]:6 ar[1]:5java java tutorials learn java study java