java面向对象内存解析
class BirthDay
{
int year;
int month;
int day;
public BirthDay(int y,int m,int d)
{
year=y;
month=m;
day=d;
}
public void setYear(int y)
{
year=y;
}
public void setMonth(int m)
{
month=m;
}
public void setDay(int d)
{
day=d;
}
public int getYear()
{
return year;
}
public int getMonth()
{
return month;
}
public int getDay()
{
return day;
}
public void display()
{
System.out.println(year+" "+month+" "+day);
}
}
public class Test
{
public static void main(String[] args)
{
Test test=new Test();
int date=9;
BirthDay b1=new BirthDay(2,22,1970);
BirthDay b2=new BirthDay(2,17,1999);
test.change1(date);
test.change2(b1);
test.change3(b2);
System.out.println(date);
b1.display();
b2.display();
}
public void change1(int i)
{
i=1000;
}
public void change2(BirthDay b)
{
b=new BirthDay(2,5,1000);
}
public void change3(BirthDay b)
{
b.setDay(33);
}
}