java封装1-7编程题
来源:1-7 编程练习
不想睡觉的橘子君
2019-08-21 13:42:05
Book类部分代码如下
public class Book {
private String name;
private String author;
private String publishing;
private double price;
// 私有属性:书名、作者、出版社、价格
public Book(String name, String author,String publishing,double price) {
this.name = name;
this.author = author;
this.setPublishing(publishing);
this.setPrice(price);
}
// 通过构造方法实现属性赋值
而BookTest类中
Book b = new Book("红楼梦","曹雪芹","人民文学出版社", 9.0d);
这么构造一个类总会报错,不知道我哪里做错了
1回答
同学你好,BookTest类中 同学的代码中有两个逗号使用的是中文的逗号,需要改为英文的逗号哦!
具体位置如下:

修改后的代码如下:
Book b = new Book("红楼梦","曹雪芹","人民文学出版社", 9.0d);如果我的回答解决了你的疑惑,请采纳!祝学习愉快!
相似问题