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.
';' expected Please reply soon
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.
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.
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