我正在用java编写一个程序,我必须创建一个包含main的类(InvoiceTest)和第二个类(Invoice)。当我运行主 InvoiceTest 类时,它应该在 Invoice 类中显示消息。我不断收到错误
Exception in thread "main" java.lang.ExceptionInInitializerError
at InvoiceTest.main(InvoiceTest.java:4)
Caused by: java.lang.RuntimeException: Uncompilable source code - constructor Invoice() is already defined in class Invoice
at Invoice.<clinit>(Invoice.java:20)
... 1 more
我不知道该怎么做,请让我知道我做错了什么以及如何解决它的任何建议。谢谢
public class InvoiceTest{
public static void main(String [] args) {
Invoice invoiceObject = new Invoice();
invoiceObject.simpleMessage();
}
}
// This is the second class. I am using NetBeans so each class is in its own window.
public class Invoice {
public void simpleMessage() {
System.out.println("This is another class");
}
}