aspose file tools*
The moose likes Java in General and the fly likes <identifier> expected error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "<identifier> expected error" Watch "<identifier> expected error" New topic

<identifier> expected error

lily jose

Joined: Oct 13, 2011
Posts: 3

I Created a class Clock with displayTime(),displayMsg() methods to display time and required message.
I am getting 2 errors ,please help me find out my mistake.
they are-
';' expected

Please reply soon

[Edit - added code tags - MB]
Matthew Brown

Joined: Apr 06, 2010
Posts: 4240

Hi Lily. Welcome to the Ranch!

It's a lot more helpful if you tell us where the errors are occuring - the compiler will tell you which line it thinks is a problem, so it's useful to pass this on.

However, I can see a few problems. For example:

- You've got a static method (clock) referring to non-static variables (Hours, Minutes, Seconds). I suspect it's meant to be a constructor, but it isn't written as a constructor.

- You refer to AM and PM as if they are variables (e.g. line 53), but they aren't defined anywhere.
I suspect you're intending them to be Strings (they really ought to be enums, but maybe you haven't learned about them yet).

- On line 108, you've got missing brackets, and the capitalisation is wrong (Clock, not clock).

This isn't a complete list. You should really write just a bit of your class at a time, compiling regularly, rather than writing it all and then seeing what mistakes you've made. That way you've got a much better idea what's caused the problem.
lily jose

Joined: Oct 13, 2011
Posts: 3

Thank ,
Now i have understood my mistake!
I am just a beginner in java, that's why i got my code messed up!
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 10916

There's nothing wrong with making mistakes - in fact, it's one of the best ways to learn. and folks around here LOVE helping, but you have to help us help you. As Matthew pointed out, if you would post the exact and complete text of your errors, that makes it even easier to help you.

Let me also give you this piece of advice: Don't write 100+ lines of code before you compile. I personally NEVER write more than 2-3 before recompiling. That way, if there is a new syntax error, I know the exact 2-3 lines where the error must be.

After compiling, I test my new code - a LOT.

I write a LOT of throw-away code. I am a BIG proponent of putting in System.out.printin() statements all over the place that say things like "got to spot 1" or "in the outer for-loop" or "value of x is " + x.

I know it sounds silly and like a waste of time, but ultimately, especially when beginning, it really will SAVE you time.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
I agree. Here's the link:
subject: <identifier> expected error
Similar Threads
Calculating download time
classes and methods
I would like to have your advice about the way I have designed the application
How to compare (Hour) with actual new Date() ?