- /*1,明确返回值类型void
- 2,明确参数列表int[] arr
- */
- class Demo1
- {
- public static void main(String[] args)
- {
- int[] arry={1,2,3,4,5};
- getEqual(arry);
- exchange(arry);
- }
- public static void getEqual(int[] arry)
- {
- for (int i =0;i<arry.length/2 ;i++ )
- {
- int temp = arry[i];
- arry[i]=arry[arry.length-1-i];
- arry[arry.length-1-i]=temp;
- }
- }
- public static void exchange(int[] arry)
- {
- for (int j= 0;j<arry.length ;j++)
- {
- System.out.println(arry[j]+" ");
- }
- }
- }
复制代码 |