怎样改变才不是空值,标红的地方怎么改都是标红,添加了参数还是会报错,求问
4条回答 默认 最新
- 不甘_ 2022-04-26 16:24关注
将题主的代码写了一点,题主可以作为参考,望采纳
public class Clock { //你的参数 String structure; String style; double price; String time; //无参构造 public Clock() { } //全参构造 public Clock(String structure, String style, double price, String time) { this.structure = structure; this.style = style; this.price = price; this.time = time; } //以下为全部参数的get和set方法 public String getStructure() { return structure; } public void setStructure(String structure) { this.structure = structure; } public String getStyle() { return style; } public void setStyle(String style) { this.style = style; } public double getPrice() { return price; } public void setPrice(double price) { this.price = price; } public String getTime() { return time; } public void setTime(String time) { this.time = time; } public static void main(String[] args) { //创建对象 Clock clock=new Clock(); // 没有给structure设置值 打印为空 System.out.println(clock.structure); // 给structure设置值,打印“我是structure” clock.setStructure("我是structure"); System.out.println(clock.structure); }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报 编辑记录
悬赏问题
- ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
- ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
- ¥15 cmd cl 0x000007b
- ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
- ¥500 火焰左右视图、视差(基于双目相机)
- ¥100 set_link_state
- ¥15 虚幻5 UE美术毛发渲染
- ¥15 CVRP 图论 物流运输优化
- ¥15 Tableau online 嵌入ppt失败
- ¥100 支付宝网页转账系统不识别账号