问题描述
我有一个继承自超类的子类,并且我注意到,如果我尝试将其打印出来,则该子类的对象似乎为空。 我以前从未遇到过这样的问题,非常感谢您的帮助。
我有这个子类:
public class OnetimeAppointment extends Appointment {
int year,month,day;
private String description;
public OnetimeAppointment(int year,int month,int day,String description)
{
super();
System.out.println(this.year);
System.out.println(year);
this.year = year;
this.month = month;
this.day = day;
this.description = description;
System.out.println(this.year);
}
public int getYear()
{
return year;
}
public int getMonth()
{
return month;
}
@Override
public boolean occursOn(int year,int day) {
// Todo Auto-generated method stub
return false;
}
@Override
public boolean equals(Object otherObject)
{
return false;
}
}
}
这是超类:
public abstract class Appointment {
private String description;
public Appointment() {
description = "";
}
public abstract boolean equals(Object otherObject);
public void setDescription(String description) {
this.description = description;
}
public String getDescription() {
return description;
}
public abstract boolean occursOn(int year,int day);
public String toString() {
return description;
}
public static void main(String args[])
{
Appointment app = new OnetimeAppointment(2020,11,1,"Dentist");
System.out.println(app);
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)