Here is my code:
public class DateDistance {
/**
* Returns whether the given year is a leap year.
*/
public static boolean isLeapYear ( long year ) {
year = Integer.parseInt(args[0]);
if (year % 400 == 0)
return true;
else {
if (year % 100 == 0)
return false;
} else {
if (year % 4 == 0)
return true;
} else {
return false;
}
}
public static void main ( String[] args ) {
System.out.println(isLeapYear(Long.parseLong(args[0])));
}
}
I keep getting the following errors and do not know what is wrong.
DateDistance.java:16: error: 'else' without 'if'
} else {
^
DateDistance.java:19: error: 'else' without 'if'
} else {
^
I got rid of the ; after the if statements and have moved the brackets around to see if they were in the wrong spot but I still could not figure it out.
Aucun commentaire:
Enregistrer un commentaire