标签:package stat public 技术 http reference ack out image
Phone类 package com.itheima_03; /* * 手机类 */ public class Phone { String brand; int price; String color; public void call(String name) { System.out.println("给"+name+"打电话"); } public void sendMessage() { System.out.println("群发短信"); } }
Phone的测试类: package com.itheima_03; /* * 手机类的测试类 */ public class PhoneDemo3 { public static void main(String[] args) { Phone p = new Phone(); p.brand = "OPPO"; p.price = 2999; p.color = "白色"; System.out.println(p.brand+"---"+p.price+"---"+p.color); Phone p2 = p; p2.brand = "魅族"; p2.price = 1999; p2.color = "蓝色"; System.out.println(p.brand+"---"+p.price+"---"+p.color); System.out.println(p2.brand+"---"+p2.price+"---"+p2.color); } }
内存图:
Two references point to the same heap memory
标签:package stat public 技术 http reference ack out image
原文地址:https://www.cnblogs.com/lzp123456-/p/9739518.html