aspose file tools*
The moose likes Beginning Java and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark ""identifier expected after this token"" Watch ""identifier expected after this token"" New topic
Author

"identifier expected after this token"

Daniel Tonks
Greenhorn

Joined: Apr 08, 2012
Posts: 6
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

Joined: Oct 27, 2005
Posts: 19670
    
  18

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Daniel Tonks
Greenhorn

Joined: Apr 08, 2012
Posts: 6
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

Joined: Oct 27, 2005
Posts: 19670
    
  18

You're welcome.
Jeff Mezzanotte
Greenhorn

Joined: Oct 12, 2013
Posts: 3
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

Joined: Aug 07, 2007
Posts: 2233
    
  47
Welcome to the Ranch.

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

Joined: Oct 12, 2013
Posts: 3
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

Joined: Aug 07, 2007
Posts: 2233
    
  47
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

Joined: Oct 12, 2013
Posts: 3
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

Joined: Oct 13, 2005
Posts: 38353
    
  23
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

Joined: Jul 04, 2013
Posts: 223

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?


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
--- Martin Fowler
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: "identifier expected after this token"