Java经典算法40例(三十一)

题目:将一个数组逆序输出。

代码:

/**
 * 数组逆序输出
 * @author cheng
 *
 */
public class ThirtyOne {
    public void converse(int[] a){
        int[] b=new int[a.length];
        for(int i=0;i1];
            System.out.println(b[i]);
        }
    }
    public static void main(String[] args) {
        int[] a={1,2,3,4,5,6};
        ThirtyOne thirtyOne=new ThirtyOne();
        thirtyOne.converse(a);
    }
}

输出结果:

6
5
4
3
2
1

你可能感兴趣的:(java)