|--数组实例化过程

java基础之【堆、栈、方法区】结构图_知识

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

|--Person实例化过程

java基础之【堆、栈、方法区】结构图_知识_02

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);
	}
}