class birthdate{
private int day;
private int month;
private int year;
public birthdate(int d,int m,int y){
day=d;
month=m;
year=y;
}
}
public class test{
public static void main(string[] args){
int date=9;
test test=new test();
test.change(date);
birthdate d1=new birthdate(7,7,1970);
}
public void change(int i){
i=1234;
}
}
public class testtransfer{
public static void main(string[] args){
int a=6;
int b=9;
swap(a,b);
system.out.println("交换结束后,a的值是"+a+";b的值是"+b); //a=9,b=6
}
public static void swap(int a,int b){
int tmp=a;
a=b;
b=tmp;
system.out.println("swap方法里,a的值是"+a+";b的值是"+b); //a=6,b=9
}
}
前
后
public class testtransfer{
public static void main(string[] args){
dataswap ds=new dataswap();
ds.a=6;
ds.b=9;
swap(ds);
system.out.println("交换结束后,ds.a的值是"+ds.a+";ds.b的值是"+ds.b); //a=9,b=6
}
public static void swap(dataswap ds){
int tmp=ds.a;
ds.a=ds.b;
ds.b=tmp;
system.out.println("swap方法里,ds.a的值是"+ds.a+";ds.b的值是"+ds.b); //a=9,b=6
}
}
class dataswap{
public int a;
public int b;
}