对于Course的方法我没有使用视频讲解的方法,而是采用了正常的get/set方法,但是在测试List的那节重写equals方法中做第四个if的判断时候,使用this关键字并不能够像之前调用course的对象方法那样出来getName(),我该如何解决?
public class Course {
private String id;
private String name;
public Course(String id, String name) {
this.id = id;
this.name = name;
}
public Course() {
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}public boolean equals(Object object){
if(this==object){
return true;
}
if(object==null){
return false;
}
if(!(object instanceof Course)){
return false;
}
Course course= (Course) object;
if(this.)//这里没有提示getName()只有getClass()但是二者无论是自己写上还是选中都会出现红色的波浪线有错误
return true;
}你不是在这个当前Course.java下写的吗? private的属性可以在类中使用,建议看一下java访问修饰符这一章节~