im getting incorrect output in my code of reversing an array,plz help
Code:import java.util.*;
class a
{
public static void main(String args[])
{
int i,temp;
int []a=new int[5];
Scanner sc=new Scanner(System.in);
System.out.println("Enter the elements of the first array");
for(i=0;i<5;i++)
{
a[i]=sc.nextInt();
}
for(i=0;i<2;i++)
{
temp=a[i];
a[i]=a[4-i];
a[4-i]=temp;
}
System.out.println("The reversed array is:");
System.out.println(a[i]);
}
}

