class Swap{
private int a;
private int b;
public static void main(String[] argv){
Swap swp = new Swap(8,3);
System.out.println(swp.toString());
}
public Swap(int a, int b){
this.a=a;
this.b=b;
}
private void confirm(){
int tmp;
if(this.a>=this.b){
tmp = this.a;
this.a=this.b;
this.b=tmp;
System.out.println("a b swaped.");
}else{
System.out.println("a b not swaped.");
}
}
private String toString(){
confirm();
return "a="+this.a+" b="+this.b;
}
}
public class compare{ //定义类
static int a,b;
public static int function(int a,int b){
int c;
if(a>=b)
c=a;
this.a=b;
this.b=c;
}
public static void main(String[] args){
compare.function(x,y);
System.out.println("a:"+compare.a+"b:"+compare.b);
}
int temp=0;
if(a>=b){
temp=a;
a=b;
b=temp;
}
System.out.println("a="+a+"---------b="+b);