day05-对象内存图-引用类型对象作为方法参数
This commit is contained in:
@@ -8,9 +8,9 @@ public class Test02 {
|
||||
p1.color = "土豪金";
|
||||
p1.price = 9999.9;
|
||||
p1.size = 6.5;
|
||||
/*System.out.println(p1.brand);
|
||||
System.out.println(p1.color);
|
||||
System.out.println(p1.price);*/
|
||||
//调用当前修改手机价格的方法
|
||||
changePhone(p1);
|
||||
System.out.println(p1.price);
|
||||
//调用手机的3个功能
|
||||
p1.show();
|
||||
p1.call("10086");
|
||||
@@ -23,9 +23,8 @@ public class Test02 {
|
||||
p2.color = "内涵黑";
|
||||
p2.price = 19999.9;
|
||||
p2.size = 6.6;
|
||||
/*System.out.println(p2.brand);
|
||||
System.out.println(p2.color);
|
||||
System.out.println(p2.price);*/
|
||||
changePhone(p2);
|
||||
System.out.println(p2.price);
|
||||
//调用手机的3个功能
|
||||
p2.show();
|
||||
p2.call("10086");
|
||||
@@ -33,4 +32,13 @@ public class Test02 {
|
||||
p2.playApp();
|
||||
|
||||
}
|
||||
|
||||
//展示手机,修改手机的价格-5000(优惠)
|
||||
public static void changePhone(Phone phone){//引用数据类型作为参数时,址传递!!!!
|
||||
//展示手机
|
||||
phone.show();
|
||||
//修改手机的价格-5000
|
||||
phone.price = phone.price - 5000;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user