1. 程式人生 > >java 內存分析

java 內存分析

ide pac urn private gif play turn one print

技術分享
package Demo;

public class Demo {
    public static void main(String[] args) {
        Demo demo = new Demo();  
        int date = 9;
        BirthDate d1 = new BirthDate(7, 7, 1970);
        BirthDate d2 = new BirthDate(5, 8, 2000);
        demo.change1(date);
        demo.change2(d1);
        demo.change3(d2);

    }
    
public void change1(int i) { i = 1234; } public void change2(BirthDate b) { b = new BirthDate(22, 2, 2004); } public void change3(BirthDate b) { b.setDay(22); } }
測試類 技術分享
package Demo;

public 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 void Display() { System.out.println(day+"-"+month+"-"+year ); } public int getDay() { return day; } public void setDay(int day) {
this.day = day; } public int getMonth() { return month; } public void setMonth(int month) { this.month = month; } public int getYear() { return year; } public void setYear(int year) { this.year = year; } }
java bean

內存分析圖:

技術分享

java 內存分析