编译我的 java 程序后,我得到了一堆错误,我不知道如何解决它们。谁能帮我一把?=/
class Date{
public static boolean isLeapYear(int year){
boolean answer = false;
if(year % 4 == 0 &&(year % 400 == 0 || year % 100 != 0))
answer = true;
else
answer = false;
return answer;
}
}
int returnDaysInMonth (int year, int month){
if (month==1||month==3||month==5||month==7||month==8||month==10||month==12){
return 31;
} else if (month==4||month==6||month==9||month==11){
return 30;
} else if(isLeapYear(year)){
return 29;
} else {
return 28;
}
}
以下是编译错误:
/Users/vlop/NetBeansProjects2/JavaLibrary1/src/Date.java:22: class, interface, or enum expected
public int returnDaysInMonth (int year, int month){
/Users/vlop/NetBeansProjects2/JavaLibrary1/src/Date.java:28: class,
interface, or enum expected
} else if (month==4||month==6||month==9||month==11){
/Users/vlop/NetBeansProjects2/JavaLibrary1/src/Date.java:32: class,
interface, or enum expected
} else if(isLeapYear(year)){
/Users/vlop/NetBeansProjects2/JavaLibrary1/src/Date.java:35: class,
interface, or enum expected
} else {
/Users/vlop/NetBeansProjects2/JavaLibrary1/src/Date.java:38: class,
interface, or enum expected
}
5 errors