day06-对象内存图-引用类型对象作为方法参数
This commit is contained in:
@@ -19,7 +19,8 @@ public class Demo03 {
|
|||||||
System.out.println(p1.color);
|
System.out.println(p1.color);
|
||||||
System.out.println(p1.price);
|
System.out.println(p1.price);
|
||||||
System.out.println(p1.size);*/
|
System.out.println(p1.size);*/
|
||||||
p1.show();
|
//p1.show();
|
||||||
|
showPhone(p1);
|
||||||
|
|
||||||
//对象的行为操作
|
//对象的行为操作
|
||||||
p1.call("10086");
|
p1.call("10086");
|
||||||
@@ -36,9 +37,19 @@ public class Demo03 {
|
|||||||
System.out.println(p2.color);
|
System.out.println(p2.color);
|
||||||
System.out.println(p2.price);
|
System.out.println(p2.price);
|
||||||
System.out.println(p2.size);*/
|
System.out.println(p2.size);*/
|
||||||
p2.show();
|
//p2.show();
|
||||||
|
showPhone(p2);
|
||||||
p2.call("10000");
|
p2.call("10000");
|
||||||
p2.sendMsg("13666666666");
|
p2.sendMsg("13666666666");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//能不能定义一个方法:接收一个手机对象,展示它的所有属性
|
||||||
|
//注意:使用了引用数据类型作为参数,传递地址,如果是基本数据类型(4类8种)传递值
|
||||||
|
public static void showPhone(Phone phone) {
|
||||||
|
System.out.println(phone.brand);
|
||||||
|
System.out.println(phone.color);
|
||||||
|
System.out.println(phone.price);
|
||||||
|
System.out.println(phone.size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user