数值交换

数组

 1 public class Swap3
 2 {
 3     public static void swap(int[] i)
 4     {
 5         int temp = i[0];
 6         i[0] = i[1];
 7         i[1] = temp;
 8     }
 9 
10     public static void main(String[] args)
11     {
12         int[] i = {1, 2};
13 
14         swap(i);
15 
16         System.out.println(i[0]);
17         System.out.println(i[1]);
18     }
19 }

 

posted @ 2015-04-23 13:01  淡纷飞菊  阅读(114)  评论(0编辑  收藏  举报