码迷,mamicode.com
首页 > 其他好文 > 详细

使用对象作为参数

时间:2019-12-15 22:05:32      阅读:92      评论:0      收藏:0      [点我收藏+]

标签:string   price   microsoft   使用   class   getc   set   family   ati   

public class Phone {
private String color;
private int price;
private String brand;

public Phone() {
}

public Phone(String color, int price, String brand) {
this.color = color;
this.price = price;
this.brand = brand;
}

public String getColor() {
return color;
}

public void setColor(String color) {
this.color = color;
}

public int getPrice() {
return price;
}

public void setPrice(int price) {
this.price = price;
}

public String getBrand() {
return brand;
}

public void setBrand(String brand) {
this.brand = brand;
}
}
========================================
public class Phone1 {
public static void main(String[] args) {
Phone one=new Phone();
one.setBrand("华为");
one.setColor("金色");
one.setPrice(8888);
phone(one);
}
public static void phone(Phone phone1){
System.out.println(phone1.getBrand());
System.out.println(phone1.getColor());
System.out.println(phone1.getPrice());
}
}

使用对象作为参数

标签:string   price   microsoft   使用   class   getc   set   family   ati   

原文地址:https://www.cnblogs.com/xzwx668/p/12045916.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!