手机类练习
public class phone { String brand; double price; String color; public void call(String who){ System.out.println("给"+who+"打电话"); } public void sendMessage(){ System.out.println("群发短信"); } public static void main(String[] args) { phone phone = new phone(); System.out.println(phone.brand); System.out.println(phone.price); System.out.println(phone.color); System.out.println("==================="); phone.brand = "iQoo"; phone.color = "渐变蓝"; phone.price = 5000; System.out.println(phone.brand); System.out.println(phone.price); System.out.println(phone.color); phone.call("牛马"); phone.sendMessage(); } }
一个对象的内存图
原创文章,作者:Carrie001128,如若转载,请注明出处:https://blog.ytso.com/270811.html