第一种:
public class jiaohuan {
public static void main(String[]args)
{
int a=1,b=2;
int m,n;
m=a;n=b;
a=n;b=m;
System.out.println("a="+a);
System.out.println("b="+b);
}
}
第二种:
public class jiaohuan2 {
public static void main(String[]args)
{
int a=1,b=2;
int c;
c=a;a=b;
System.out.println("a="+a);
b=c;
System.out.println("b="+b);
}
}
第三种:
public class jiaohuan3 {
public static void main(String[]args)
{
int a=1,b=2;
System.out.println("a="+b+",b="+a);
}
}
原文:http://www.cnblogs.com/sunyuanlong/p/7225839.html