我正在编写一个必须符合前提条件的代码,如果条件都满足,那么它将返回true.我尝试了多个"if"语句,但这似乎不起作用.嵌套if语句似乎不是这里的答案,我不认为"else if"语句可行.我要问的是,这样做的正确方法是什么?我写if语句错了吗?
继承我的代码:
public static boolean isLegitimate(int mon, int day, int year){
// February has 29 days in any year evenly divisible by four,
// EXCEPT for centurial years which are not also divisible by 400.
// TODO 1: Check if a date is valid.
//checks to see if the months are between 1 and 12
if((mon >= 1) && (mon <= 12)) {
}
//checks to see if the years are greater than 1
if (year > 0){
} …Run Code Online (Sandbox Code Playgroud)