【发布时间】:2018-08-21 15:11:23
【问题描述】:
这可能是一个大的菜鸟错误,但我不明白为什么我的 IDE 不喜欢我的方法调用。
//main here:
isLeapYear(-1600);
isLeapYear(1600);
isLeapYear(2017);
isLeapYear(2000);
public static boolean isLeapYear(int year){
if(year >= 1 && year <= 9999) {
if (year % 400 == 0) {
System.out.println("true");
return true;
} else if (year % 4 == 0 && year % == !100) {
System.out.println("true");
return true;
} else {
System.out.println("false");
return false;
}
//return false if not in year range
System.out.println("false");
return false;
}
}
}
【问题讨论】:
-
您遇到了什么错误?您的方法调用实际上是在
main函数内吗? -
请发布整个代码。对了,我只能假设:你的方法是在 inside
main方法中声明的吗? -
year % == !100大概是指year % 100 != 0