- class Test {
- public static void main(String[] args)
- {
- /*int a = 10;
- int b = 20;
- System.out.println("a:"+a+",b:"+b);
- change(a,b);
- System.out.println("a:"+a+",b:"+b);
- */
- int[] arr = {1,2,3,4,5};
- change(arr);
- System.out.println(arr[1]);
- System.out.println("================");
- for(int x =0;x < arr.length;x++)
- {
- System.out.println("没反转前的数值"+arr[x]);
- }
- System.out.println("***********************");
- fanZhuan(arr);
- System.out.println("---------------------");
- for(int x =0;x < arr.length;x++)
- {
- System.out.println("调用反转函数后的"+arr[x]);
- }
- }
- public static void fanZhuan(int[] arr)
- {
- int[] brr =new int [arr.length];
- int temp = arr.length -1;
- for(int x = 0;x < arr.length;x++)
- {
- brr[temp-x] =arr[x];
- }
- arr = brr;//数组数据反序列
- for(int x =0;x < arr.length;x++)
- {
- System.out.println("反转函数中的调用输出"+arr[x]);
- }
- }
- public static void change(int a,int b)
- {
- System.out.println("a:"+a+",b:"+b);
- a = b;
- b = a + b;
- System.out.println("函数调用输出"+"a:"+a+",b:"+b);
- }
- public static void change(int[] arr)
- {
- for(int x=0; x<arr.length; x++)
- {
- if(arr[x]%2==0)
- {
- arr[x]*=2;
- }
- }
- }
-
-
- }
-
复制代码
|
|