请问下面这两种写法有什么不同?我觉得C也可以啊,为什么不对,是因为不严谨吗? 5
B.publicbooleanequals(Objectobj){if(objinstanceofStudent){Studentstu=(Student)obj;ret...
B. public boolean equals(Object obj) {
if (obj instanceof Student) {
Student stu = (Student) obj;
return stu.name.equals(this.name);
} else {
return false;
}
}
C.public boolean equals(Object obj) {
if (obj instanceof Student) {
return obj.name.equals(this.name);
} else {
return false;
}
} 展开
if (obj instanceof Student) {
Student stu = (Student) obj;
return stu.name.equals(this.name);
} else {
return false;
}
}
C.public boolean equals(Object obj) {
if (obj instanceof Student) {
return obj.name.equals(this.name);
} else {
return false;
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询