Ok, this Leap Year program is really starting to get to me. While seemingly simple, here are the error messages I get when I try to compile.
C:\Documents and Settings\Benjamin Q. Chau\WRITTENPROGRAMS>javac Leap.java Leap.java:13: '.class' expected if (boolean == true) ^ Leap.java:28: ')' expected ^ Leap.java:29: illegal start of expression } ^ 3 errors
Why would I need to tag on ".class" to the boolean keyword? Overall, I'm not understanding why I'm getting these error messages. I checked and checked to make sure I closed all brackets/parantheses. Any help would be great. Here's my code:
[ November 17, 2008: Message edited by: Benjamin Chau ]
"boolean" isn't a variable, but a keyword. You mustn't used keywords or other reserved words out of their intended context.
"== false" and "== true" are errors. If you write = false by mistake. you can get all sorts of errors. You write if(leapYear) or if(!leapYear).
Joined: Oct 05, 2008
Thanks Campbell. That was silly of me to use boolean as a variable. These late nighters screw with your mind I guess. I'm going back to edit the code now.
James suggested I change the syntax around a bit in one of his earlier posts but I've been thinking that that would change the logic and make the Leap Year program not work correctly. So I took that into account in my editing...
Joined: Oct 13, 2005
It ought to readNever use == false or == true because you can get nasty errors if you write = instead of == by mistake.