1、实体类BirthDate
1package Demo; 2 3public class BirthDate { 4 private int day; 5 private int month; 6 private int year; 7 8 public BirthDate(int d, int m, int y) { 9 day = d; 10 month = m; 11 year = y; 12 } 13 public void Display() { 14 System.out.println(day+"-"+month+"-"+year ); 15 } 16 public int getDay() { 17 return day; 18 } 19 20 public void setDay(int day) { 21 this.day = day; 22 } 23 24 public int getMonth() { 25 return month; 26 } 27 28 public void setMonth(int month) { 29 this.month = month; 30 } 31 32 public int getYear() { 33 return year; 34 } 35 36 public void setYear(int year) { 37 this.year = year; 38 } 39 40}
2、测试类
1package Demo; 2 3public class Demo { 4 public static void main(String[] args) { 5 6 Demo demo = new Demo(); 7 int date = 9; 8 BirthDate d1 = new BirthDate(7, 7, 1970); 9 BirthDate d2 = new BirthDate(1, 1, 2000); 10 demo.change1(date); 11 demo.change2(d1); 12 demo.change3(d2); 13 14 } 15 public void change1(int i) { 16 i = 1234; 17 } 18 public void change2(BirthDate b) { 19 b = new BirthDate(22, 2, 2004); 20 } 21 public void change3(BirthDate b) { 22 b.setDay(22); 23 } 24}
3、内存分析
- Demo demo = new Demo();

- int date = 9;
