package com.tutorial4u;
import java.util.Arrays;
public class ArrayReverse
{
public static void main(String[] args)
{
int i;
int a[] =
{1,14,5,17,4,2};
for (i=0;i<a.length/2;i++)
{
int temp = a[i];
a[i]=
a[a.length-1-i];
a[a.length-1-i]= temp;
}
System.out.println("Reverse Array
is :"+Arrays.toString(a));
}
}
Reverse Array is :[2, 4, 17, 5, 14, 1]
No comments:
Post a Comment