日期:2014-05-20 浏览次数:20700 次
package cn.sky; public class Integer { private int num; public Integer(int num) { this.num = num; } public int getNum() { return num; } public void setNum(int num) { this.num = num; } @Override public String toString() { return num + ""; } } class Test { public static void main(String[] args) { Integer a = new Integer(89); Integer b = new Integer(43); swap(a,b); System.out.println(a + "---" + b); } static void swap(Integer a, Integer b) { int temp = b.getNum(); b.setNum(a.getNum()); a.setNum(temp); } }