Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/391.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 打印对账单时给出;找不到符号“;消息_Java_Netbeans - Fatal编程技术网

Java 打印对账单时给出;找不到符号“;消息

Java 打印对账单时给出;找不到符号“;消息,java,netbeans,Java,Netbeans,我在玩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

我在玩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语句抛出消息“找不到符号”


知道问题可能是什么吗?

由于whatDay类中对println的调用未包含在方法中,因此出现了错误。

问题是
系统.out.println()
尝试将System.out.println()放入一个方法中。
例如:

public class WhatDay {
    // Constructor
    public WhatDay() {
        System.out.println()
    }
}
顺便说一句:你应该以大写字母开始类名


玩得开心:)

@zan,如果这个答案适合你,请。