- class Reve
- {
- public static void main(String[] args)
- {
- int[] list = {1,2,3,4,5};
- reverse(list);
- for (int i = 0; i< list.length;i++)
-
- System.out.println(list[i]+ " ");
-
-
- }
- public static void reverse(int[] list){
- int[] newlist = new int[list.length];
- for (int i = 0;i<list.length ;i++ )
-
- newList[i] = list[list.length - 1 - i];
-
-
- list = newList;
- }
- }
复制代码
下面这个方法不知道起到了什么作用,有木有它,输出结果都一样~~~ |