This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes illegal start of type! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "illegal start of type!" Watch "illegal start of type!" New topic
Author

illegal start of type!

dean lin
Greenhorn

Joined: May 11, 2009
Posts: 3
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

Joined: Mar 30, 2007
Posts: 46


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
Ranch Hand

Joined: Jan 12, 2009
Posts: 917

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



My Website: [Salvin.in] Cool your mind:[Salvin.in/painting] My Sally:[Salvin.in/sally]
dean lin
Greenhorn

Joined: May 11, 2009
Posts: 3
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

Joined: Oct 13, 2005
Posts: 37897
    
  22
The Rectangle class ought to be in a file of its own.
For the other things, have a look at our Chicken Coop.
 
 
subject: illegal start of type!
 
Similar Threads
socket not accepting data 2nd time
Do while error, I'm going crazy
Help with Value Returning Methods
Basic question about constructors
accessing private variable of another object of same class