// 使用对象类型作为方法的返回值
当使用一个对象类型作为方法的返回值时:
返回值其实就是对象的地址值。
public class Demo05PhoneReturn {
public static void main(String[] args) {
Phone two = getPhone();
System.out.println(two.brand); // 香蕉
System.out.println(two.price); // 8348.0
System.out.println(two.color); // 玫瑰黑
}
public static Phone getPhone() {
Phone one = new Phone();
one.brand = "香蕉";
one.price = 8348.0;
one.color = "玫瑰黑";
return one;
}
}