/**
* Java Interview Question
* Reversing an array
*/
package com.belazy.javaprograming;
/**
* @author
*
*/
public class ReverseArray {
/**
* @param args
*/
public static void main(String[] args) {
int[] a = {1,2,3,4,5,6,7};
int[] b = new int[a.length];
int r = a.length;
for(int i=0; i<a.length; i++){
r--;
b[r] = a[i];
}
for(int i=0;i<b.length;i++){
System.out.println(b[i]);
}
}
}
No comments:
Post a Comment
Your feedback may help others !!!