可能重复:
Why does my program only outputs one result instead five?
/ *
*查找一年是否跳跃
* /
public class LeapYear{
public static void year(int leapYear){
System.out.println(leapYear);
}
public static void main (String[] args) {
leapYear(2010);
leapYear(2008);
leapYear(2010);
leapYear(2008);
leapYear(1565);
String result;
if (year % 400 == 0) {
result = "is a leap year.";
} else if (year % 100 == 0) {
result = "is not a leap year.";
} else if (year % 4 == 0) {
result = "is a leap year.";
} else {
result = "is not a leap year.";
}
System.out.println(year + ": " + result);
}
}
为什么所有的leapYear()都没有调用?
答案 0 :(得分:2)
您没有定义任何名为leapYear的函数。
答案 1 :(得分:1)
leapYear()
不是上面定义的函数。 LeapYear.year()
是。如果你改变它们,它将起作用:)