1. 程式人生 > >java基礎之【堆、棧、方法區】結構圖

java基礎之【堆、棧、方法區】結構圖

|--陣列例項化過程

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

|--Person例項化過程


package com.domain;
class Person {
	public String name;
	public String gender;
	public int age;
	public void meals() {
		System.out.println("吃飯.....");
	}
	public void shudy() {
		System.out.println("學習....");
	}
	public void slepp() {
		System.out.println("睡覺..");
	}
}
public class PersonMain {
	public static void main(String[] args) {
		Person p1 = new Person();
		p1.meals();
		
		Person p2 = new Person();
		p2.shudy();
		
		Person p3 = p2;
		p3.slepp();
		System.out.println("--------------");
		p1.name = "鄭源";
		p2.name = "周杰倫";
		p3.name = "周董";
		System.out.println(p1.name);
		System.out.println(p2.name);
		System.out.println(p3.name);
	}
}