方法1: public class NumChange { public static void main(String[] args) { int a = 23; int b = 34; int c; c = a;a = b;b = c; System.out.println("a="+a+",b="+b); } } 方法2: public class NumChange { public static void main(String[] args) { int a = 23; int b = 34; a = a + b; b = a - b; a = a - b; System.out.println("a="+a+",b="+b); } }