class s1
{
public static void reverseArray(int[] arr)
{
for(int start=0,end=arr.length-1; start<end; start++,end--)
{
swap(arr,start,end);
}
}
public static void swap(int arr[],int a,int b)
{
int temp = arr[a];
arr[a] = arr[b];
arr[b] = temp;
}
public static String arrayToString(int[] arr)
{
String str = "[";
for(int x=0; x<arr.length;x++)
{
if(x!=arr.length-1)
str = str + arr[x] + ",";
else
str = str + arr[x] + "]";
}
return str;
}
public static void main(String[] args)
{
int a[]={1,2,3,4,5,6,7,8,9};
reverseArray(a);
System.out.print(arrayToString(a));
}
}
{
public static void reverseArray(int[] arr)
{
for(int start=0,end=arr.length-1; start<end; start++,end--)
{
swap(arr,start,end);
}
}
public static void swap(int arr[],int a,int b)
{
int temp = arr[a];
arr[a] = arr[b];
arr[b] = temp;
}
public static String arrayToString(int[] arr)
{
String str = "[";
for(int x=0; x<arr.length;x++)
{
if(x!=arr.length-1)
str = str + arr[x] + ",";
else
str = str + arr[x] + "]";
}
return str;
}
public static void main(String[] args)
{
int a[]={1,2,3,4,5,6,7,8,9};
reverseArray(a);
System.out.print(arrayToString(a));
}
}