Error: Main method not found in class TextBook, please define the main method as: public static void main(String[] args)
我试着编译它,它说没有错误。但当我运行程序时,它会说:
Error: Main method not found in class TextBook, please define the main
method as: public static void main(String[] args)
所以当我添加
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | import java.util.*; public class Book { private int pageNum; private String title; Date today = new Date(); public Book(int pn, String name) { pageNum = pn; title = name; } //Setter/Getter for pageNum public int getpageNum() { return pageNum; } public void setpageNum(int pn) { pageNum = pn; } //Setter/Getter for Title public String getTitle() { return title; } public void setTitle(String name) { title = name; } public void display() { System.out.println("Book.java" +" by Tyler" + today); System.out.println("Book Title:" + title +" Number of Pages:" + pageNum); } } |
用于bookbook.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | public class TextBook extends Book { private String gradeLevel; public TextBook(int pageNum, String title, String gl) { super(pageNum, title); gradeLevel = gl; } //Setter/Getter for gradeLevel public String getGradeLevel() { return gradeLevel; } public void setGradeLevel(String g) { gradeLevel = g; } public void display() { super.display(); System.out.println("Grade Level:" + gradeLevel); } } |
用于demobook.java
1 2 3 4 5 6 7 8 9 10 11 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | class Maximum_num { public void num() { int x=5; int y=6; int z=7; if(x>y) { if(x>z) { System.out.println("x is maximum number"); } else { System.out.println("z is maximum number"); } } else if (y>z) { System.out.println("z is maximum number"); } } } public class Calculate { public static void main(String [] args) { Maximum_num mn=new Maximum_num(); mn.num(); } } |
删除部分-
只能用EDCOX1×0的方法运行Java文件。
在您的情况下,只能运行