Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

illegal start of type!

 
dean lin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All

Please help me ! How can I solve this problem

After complier this code I got this error message

C:\Dean>javac Menu3.java
Menu3.java:62: illegal start of type
while(true){
^
Menu3.java:102: class, interface, or enum expected
}
^
2 errors

Thank you!

 
jittu goud
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


you are referring a static main method argument from a nonstatic innner class...which is not allowed

the best way is read the arguments before the innerclass in to a final variable.........and use it in the code




r1.drawRect() returns a void ...so what do you want to print using a method which returns a void...

you can skip the print statement...and use the r1.drawRect(); directly
 
salvin francis
Bartender
Posts: 1263
10
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is the error message i got when compiled:




The first error is self explainatory,

The second error means : what do you expect to be appended to string? the return type of the function is void.

Bad programming practices:

Defining a class in main
No proper indentations.
Conditional Statements, Loops whose statements are not in braces


 
dean lin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All

Thank you very much for your suggestion

I modify my code as below it can work now

But still don't understand this hint

Bad programming practices:

Defining a class in main
No proper indentations.
Conditional Statements, Loops whose statements are not in braces

Would you please explain it more detail or please give me some document about it

I will try to understand it






 
Campbell Ritchie
Sheriff
Posts: 48386
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Rectangle class ought to be in a file of its own.
For the other things, have a look at our Chicken Coop.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic