怎样改变才不是空值,标红的地方怎么改都是标红,添加了参数还是会报错,求问
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 如何实验stm32主通道和互补通道独立输出
- ¥30 这是哪个作者做的宝宝起名网站
- ¥60 版本过低apk如何修改可以兼容新的安卓系统
- ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
- ¥50 有数据,怎么建立模型求影响全要素生产率的因素
- ¥50 有数据,怎么用matlab求全要素生产率
- ¥15 TI的insta-spin例程
- ¥15 完成下列问题完成下列问题
- ¥15 C#算法问题, 不知道怎么处理这个数据的转换
- ¥15 YoloV5 第三方库的版本对照问题