• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

"identifier expected after this token"

 
Daniel Tonks
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this error after watching exactly someone was doing on YT in a tutorial. His worked but mine didn't...

Heres my code


Please help!
I've only been at Java for a few hours, and I really want to press on! :P

 
Rob Spoor
Sheriff
Pie
Posts: 20611
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

I've added code tags and some better indentation to your post. Especially that better indentation should show you that statement is not where you want it to be - inside the logoTimer anonymous class definition.
 
Daniel Tonks
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah! Thank you!

I was doing this in eclipse and the indenting seems a little glitchy for me. I see my error now. Thanks
 
Rob Spoor
Sheriff
Pie
Posts: 20611
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
Jeff Mezzanotte
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:Welcome to the Ranch!

I've added code tags and some better indentation to your post. Especially that better indentation should show you that statement is not where you want it to be - inside the logoTimer anonymous class definition.


Im having the same problem can you post the updated code?
 
Tony Docherty
Bartender
Posts: 2971
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Why don't you post your code and we will help you find the problem.
 
Jeff Mezzanotte
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony Docherty wrote:Welcome to the Ranch.

Why don't you post your code and we will help you find the problem.


 
Tony Docherty
Bartender
Posts: 2971
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To fix the code do as Rob suggested to the original poster.

If it's not immediately obvious, then starting at the line where you create a new Thread object, count +1 for each opening brace and -1 for each closing brace. When you are back to 0 you have finished the local class definition and after the final closing brace is where the errant line goes. If your count goes to -1 rather than going positive then you are starting the block with a closing brace instead of an opening brace.
 
Jeff Mezzanotte
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony Docherty wrote:To fix the code do as Rob suggested to the original poster.

If it's not immediately obvious, then starting at the line where you create a new Thread object, count +1 for each opening brace and -1 for each closing brace. When you are back to 0 you have finished the local class definition and after the final closing brace is where the errant line goes. If your count goes to -1 rather than going positive then you are starting the block with a closing brace instead of an opening brace.


looks like it was the brace on line 18 thanks
 
Campbell Ritchie
Sheriff
Pie
Posts: 49848
70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is deceptively easy to suffer that sort of error, if you write your code forwards. Set up automatic indentation on your text editor and life will be a lot easier. Then you need to learn to write code backwards (at least in part). Writing backwards makes it much easier to ensure you have matched {}, and correct indentation allows you always to see how many {} you have got.
 
Partheban Udayakumar
Ranch Hand
Posts: 496
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff and Daniel,

Try removing the semicolon after the closing braces which is present before logoTimer.start();, the place where you get your error

And can you tell me why have you used }; after the error line?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic