我在玩java,遇到以下问题。打印声明给出“无法找到符号”消息
我有以下类
class Training{
public static void main(String[]args){
book firstBook = new book("Hamlet","William Shakespeare");
book secondBook = new book("Heart of Darkness", "Joseph Conrad");
book thirdBook = new book("Database Design","M Hernandez");
System.out.println();
System.out.println("Total number of books is " + book.noOfBooks + "\n");
System.out.println();
}
}
public class book {
private String name;
private String author;
private int id;
public static int noOfBooks = 0;
public book(String n, String a){
name = n;
author = a;
id = ++noOfBooks;
System.out.printf("The book you've just created is %s\n", this);
}
public String toString(){
return String.format("%s by %s id %d", name, author, id);
}
public String getName(){
return name;
}
public String getAuthor(){
return author;
}
public int getID(){
return id;
}
}
public class whatDay {
System.out.println();
}
的NetBeans抛出一个消息在whatDay
类print语句“无法找到符号”。
任何想法可能是什么问题?
嗨mhp,非常感谢。我工作:) – zan
不客气。 – mhmpl
@赞,如果这个答案适合你,请[标记为已接受](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235)。 –