• Post Reply Bookmark Topic Watch Topic
  • New Topic

What does - class, interface, or enum expected - mean?  RSS feed

 
Danny Broadwater
Ranch Hand
Posts: 65
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question I have is... what does class, interface, or enum expected mean? The last five lines give me this answer class, interface, or enum expected. I also get no main class. Would you please help me.

 
Chan Ag
Rancher
Posts: 1090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Danny Broadwater wrote:The question I have is... what does class, interface, or enum expected mean? The last five lines give me this answer class, interface, or enum expected. I also get no main class. Would you please help me.



We'll address the last five lines. But first, what is the following code supposed to do? Do those lines compile? If not, what does the compiler error say?


What is the program supposed to do ( What is your problem statement )?
 
Danny Broadwater
Ranch Hand
Posts: 65
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Showing Lesson5Activityl9 is a public class,
 
Chan Ag
Rancher
Posts: 1090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, the public keyword makes it a public class.

But what is the following part for?



Do we write the extends keyword inside the class body? Can a class inherit from more than one class?

Here is an example of the correct syntax of a class that extends another class.



In Java, a class cannot extend from more than one class ( Java does not allow multiple inheritance ). So the following is wrong.



Also the extends keyword goes with the class name outside the class body as shown in my first example. So the following would be wrong.



So given the above, how would you fix the first error in your code? Also my question still stands - what is your problem statement ( what is the program supposed to do )?

Chan.
 
Danny Broadwater
Ranch Hand
Posts: 65
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lesson 19: Create a line Drawing Application with Swing. I am using NetBeans IDE 7.4. I redid the main as follows:



The errors are as follows




I am thinking about starting over on this project.... But would like to hear what you say. I can see that I tried combining 2 classes together, and my ending brackets are all wrong, plus more problems. Thanks for your time and effort Danny.
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have already been told not to combine two classes; if they are public they must be in separate files.
Sort out the first compiler error and re‑compile. This sort of printout shows the error of writing hundreds of lines and then compiling. Compile after every 5 lines; then the errors will be few and easier to find.
 
Danny Broadwater
Ranch Hand
Posts: 65
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your time and effort. I will recompile and start over. Thanks Danny.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!