编译时函数cannot be resolved

xiaozhupiggg xiaozhupiggg 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
函数功能:
定义一个日期类,有年,月,日属性,包含无参的和有参的构造方法,有完成如下功能的方法:1)、判断该年是否为闰年,2)、判断当月的天数,3)、计算该日期是本年的第多少天,4),计算本年还剩多少天,在main方法中,输入年,月,日,根据输入创建该类的对象,并调用它的相关方法。

类体:
public class Date {
private int year,month,day;
public int[]a = {0,31,28,31,30,31,30,31,31,30,31,30,31};
public int[]b = {0,31,29,31,30,31,30,31,31,30,31,30,31};
public Date(){

}
public void setYear(int year){
this.year = year;
}
public int getYear(int year){
return year;
}
public void setMonth(int month){
this.month = month;
}
public int getmonth(int month){
return month;
}
public void setDay(int day){
this.day = day;
}
public int getDay(int day){
return day;
}
public Date(int year,int month,int day){

}
public char isLeapYear(int year){
if(year%400==0||year%4==0&&year%100!=0){
return '是';
}else {
return '否';
}
}
public int daysThisMonth(char isLeapYear,int month){
if (isLeapYear=='是'){
return a[month];
}else{
return b[month];
}
}
public int daysThisYear(char isLeapYear,int month,int day){
int sum = 0;
if(isLeapYear=='是'){
for(int i=0;i<month;i++){
sum+=a[i];
}
return sum+day;
}else{
for(int i=0;i<month;i++){
sum+=b[i];
}
return sum+day;
}

}


}


import java.util.Scanner;
public class testDate {


public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.println("请输入年份:");
int year = s.nextInt();
Scanner m = new Scanner(System.in);
System.out.println("请输入月份");
int month = m.nextInt();
System.out.println("请输入日:");
Scanner d = new Scanner(System.in);
int day = d.nextInt();
Date D1 = new Date();
D1.setYear(year);
D1.setMonth(month);
D1.setDay(day);
Date D2 = new Date(2000,2,14);

System.out.println(D1.getYear(year)+"年是闰年吗?"+D1.isLeapYear(year));
System.out.println(D1.getmonth(month)+"月有"+D1.daysThisMonth(isLeapYear, month)+"天");
System.out.println("它是本年的第"+D1.daysThisYear(isLeapYear, month, day)+"天");


}

}

问题:在编译testDate时,倒数两行都显示:isLeapYear cannot be resolved


请教各位大侠~
...全文

相关推荐

java eclipse 出现 xxx cannot be resolved to a type 错误解决方法

,例如 "xxx cannot be resolved to a type" 错误。

weixin_38747444

Eclipse中“cannot be resolved to a type”报错原因与排查指南

Java开发中,类型解析是编译期的核心环节,编译器需为每个简单类名找到唯一全限定名。当Eclipse无法将某个类型解析到构建路径中的类时,便会出现“cannot be resolved to a type”错误。这类问题通常源于import缺失、classpath配置错误、Maven或Gradle依赖未同步、以及IDE索引缓存过期。理解类型解析顺序和JDT增量编译原理,有助于快速定位问题。通过检查import、刷新构建路径、清理项目重建索引、用jar tf验证依赖完整性等步骤,可系统解决该错误。本文提供了一

程序员良许

estableRuntimeException cannot be resolved 解决

在Java编程环境中,我们经常会遇到编译错误提示“XXX cannot be resolved”,这通常意味着系统无法找到指定的类或方法。

woshiloudou

导入工程的“The import android cannot be resolved”错误解决方法

通过遵循上述步骤,大多数情况下都能有效解决“The import android cannot be resolved”的错误。

锦瑟six

详解 问题:HttpServlet cannot be resolved to a type

在Java Web开发中,遇到"HttpServlet cannot be resolved to a type"的问题时,通常表示编译器无法识别HttpServlet类。这个问题可能出现在尝试导入或

weixin_38720322
评论 7
收藏 已收藏
分享
返回顶部
xiaozhupiggg
Java SE 62,620 成员 307,251 内容