首页上一页 1 下一页尾页 1 条记录 1/1页
疑问
发表在Java图书答疑
2015-10-13
是否精华
是
否
版块置顶:
是
否
我在看《Java从入门到精通(实例版)第三版》p157页范例一,我按照书上讲的建类,为何不能得到结果,显示为设置主类,如何解决?
public class Book {
private String title;
private String author;
private double price;
public Book(String title,String author,double price){
this.title=title;
this.author=author;
this.price=price;
}
public String getTitle(){
return title;
}
public String getAuthor(){
return author;
}
public double getPrice(){
return price;
}
}
小闰土 2015/10/13 15:41:08
public class Test {
public static void main(string[] args){
Book book=new Book("《Java从入门到精通》","明日科技",59.8);
System.out.println("书名:"+book.getTitle());
System.out.println("作者:"+book.getAuthor());
System.out.println("价格:"+book.getPrice()+"元");
}
}
}
把运行成功的步骤和如何做的写出来,截屏也可以。谢谢!
public class Book {
private String title;
private String author;
private double price;
public Book(String title,String author,double price){
this.title=title;
this.author=author;
this.price=price;
}
public String getTitle(){
return title;
}
public String getAuthor(){
return author;
}
public double getPrice(){
return price;
}
}
小闰土 2015/10/13 15:41:08
public class Test {
public static void main(string[] args){
Book book=new Book("《Java从入门到精通》","明日科技",59.8);
System.out.println("书名:"+book.getTitle());
System.out.println("作者:"+book.getAuthor());
System.out.println("价格:"+book.getPrice()+"元");
}
}
}
把运行成功的步骤和如何做的写出来,截屏也可以。谢谢!