• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Need Java help!

pcnerd37

Senior member
Im having trouble compiling a class for my program, and for the life of me i cant see why. My compiler is giving me errors at the leap module. Any help you guys could give me would be great!
 
Any help you can give us would be great. Please post the compiler output.

At first glance, your bracketing looks to be messed up starting just before the switch() in the checkYear() method.

And what is the "leap module"? 😕
 
The compiler error says: LY.java:92: illegal start of expression
public boolean leap(int year)

Here is the module.
 
Originally posted by: pcnerd37
The compiler error says: LY.java:92: illegal start of expression
public boolean leap(int year)

Here is the module.


Need to declare verify boolean before using it in Leap function? Also your return is missing the 'n' at the end
 
Mind telling us what line 92 is?

So it could be the brackets (something is definitely wrong there, and the compiler often reports those errors much further than the original mistake). Could also be that you've missed the n on the end of return.

That is not a module, it's a method.
 
Originally posted by: neegotiator
Originally posted by: pcnerd37
The compiler error says: LY.java:92: illegal start of expression
public boolean leap(int year)

Here is the module.


Need to declare verify boolean before using it in Leap function? Also your return is missing the 'n' at the end
verify is defined up at the top of the class.
 
Originally posted by: kamper
Mind telling us what line 92 is?

So it could be the brackets (something is definitely wrong there, and the compiler often reports those errors much further than the original mistake). Could also be that you've missed the n on the end of return.

That is not a module, it's a method.

The n has been fixed. I meant method, but one of my friends keeps saying module to me and i just said it by accident. anyway, that line is:

public boolean leap(int year)
 
Yeah, revisit your brackets. I can point out exactly which one is wrong, and I would, but part of learning to program is figuring out how to interpret compiler errors and tracing it back to the error. You'll benefit a lot if you stare at it for a while until you see the mistake.
 
Originally posted by: neegotiator
is that LY.java in toString() method supposed to be there? what is that?

No, that was not supposed to be there. Its gone now. This code was writting by another person in my group, im just trying to clean it up and make it work.
 
On that note, the entire toString() method is pointless. What's written there is exactly what'll happen if you don't implement the method. The import java.lang.*; is also redundant. I'm surprised the compiler didn't complain about it. Sorry to nitpick 😛
 
Originally posted by: kamper
On that note, the entire toString() method is pointless. What's written there is exactly what'll happen if you don't implement the method. The import java.lang.*; is also redundant. I'm surprised the compiler didn't complain about it. Sorry to nitpick 😛

toString() is redefined in the parent class, so i think its ok. the import has been removed. Nitpicking is good, it helps me learn alot and write better code, im greatful for it.
 
Originally posted by: pcnerd37
Originally posted by: kamper
On that note, the entire toString() method is pointless. What's written there is exactly what'll happen if you don't implement the method. The import java.lang.*; is also redundant. I'm surprised the compiler didn't complain about it. Sorry to nitpick 😛

toString() is redefined in the parent class, so i think its ok. the import has been removed. Nitpicking is good, it helps me learn alot and write better code, im greatful for it.
I didn't say the toString() wasn't ok, just that it's pointless. It doesn't matter if it's implemented in the parent or not because java.lang.Object implements it. Come to think of it, Object is the parent anyways 😛
 
Back
Top