aspose file tools*
The moose likes Beginning Java and the fly likes error: not a statement, '.class' expected, illegal start of expression, ';' expected Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "error: not a statement, Watch "error: not a statement, New topic
Author

error: not a statement, '.class' expected, illegal start of expression, ';' expected

Dustin Schreader
Ranch Hand

Joined: May 25, 2009
Posts: 102
I get these error messages:

In this line: 23
In this method:
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
The else part is missing a opening and a closing brace {}. The firstNum variable will not be visible if the braces are not provided.
Line #21
Satyen Singh
Greenhorn

Joined: Oct 05, 2011
Posts: 21

hi Dustin,

please, specify the exact line on which you are getting error.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11476
    
  16

Satyen Singh wrote:please, specify the exact line on which you are getting error.

I'm pretty sure that's what he meant when he said:
In this line: 23
In this method:

As a general note, you should indeed ALWAYS use braces, even if not technically required. And even if you DO use braces, your firstNum will go out of scope once you exit from said braces, and will not be visible by the time you enter your switch on line 32 of the provided code.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Dustin Schreader
Ranch Hand

Joined: May 25, 2009
Posts: 102
I will try using the braces, thank you.
 
 
subject: error: not a statement, '.class' expected, illegal start of expression, ';' expected