java中这种问题怎么解决 - 爱问答

(爱问答)

java中这种问题怎么解决

 

java中这种问题怎么解决

1、成员变量和局部变量  一个在方法外部类内部,一个在方法内部


2、

public class MP3 {

public String brand;

public double weight;

public String type;

public double price;

public String getBrand() {

return brand;

}

public void setBrand(String brand) {

this.brand = brand;

}

public double getWeight() {

return weight;

}

public void setWeight(double weight) {

this.weight = weight;

}

public String getType() {

return type;

}

public void setType(String type) {

this.type = type;

}

public double getPrice() {

return price;

}

public void setPrice(double price) {

this.price = price;

}

@Override

public String toString() {

return "MP3 [brand=" + brand + ", weight=" + weight + ", type=" + type

+ ", price=" + price + "]";

}

 

public static void main(String[] args) {

MP3 mp3 =new MP3();

mp3.setBrand("爱国者F928");

mp3.setWeight(12.4);

mp3.setType("内置锂电池");

mp3.setPrice(499);

System.out.println(mp3.toString());

}

 

}


相关标签:java

下一篇:VC.6.0Compiling...,Errorspawningcl.exe错误

上一篇:自己组装电脑的话是直接购买主板套装合算还是分别买合算?

热门标签:
excel 网盘 破解 word dll
最新更新:
微软重新评估新的Outlook的使用时机 联想推出搭载联发科Helio G80芯片组的Tab M9平板 英特尔创新大赛时间确定! 微软Edge浏览器在稳定渠道中推出Workspaces功能 英伟达RTX4060TiGPU推出MaxSun动漫主题! 谷歌地图为用户提供了街景服务! GameSir 在T4 Kaleid中推出了一款出色的控制器! 微软开始在Windows 11 中测试其画图应用程序的新深色模式! LG电子推出全球首款无线OLED电视 英伟达人工智能芯片崭露头角! Steam Deck可以玩什么游戏-Steam Deck价格限时优惠 雷蛇推出CobraPro鼠标 Kindle电子阅读器可以访问谷歌商店吗 Windows10如何加入组策略 window10图片查看器怎么没有了?