java集合的问题

/**

 * @author 墨风

 */

public class Student implements Comparable{

//名字

String name;

//分数

int score;

int age;

public Student(String name,int score){

this.name = name;

this.score = score;

}

public String toString(){

return name+"得了"+score+"分";

}

public boolean equals(Object o){

if(this==o){

return true;

}

if(o instanceof Student){

Student stu = (Student) o;

if(stu.name.equals(this.name)&&(stu.score==this.score)){

return true;

}

}

return false;

}

public int hashCode(){

return score/10;

}

23行的this指的是

慕先生4463397
浏览 1006回答 2
2回答

窗下有梧桐

this指的是当前对象,比如你调用a.equals(b),那么this指的就是a对象,望采纳。

窗下有梧桐

。。那个不是0啊,是一个object类型的对象o
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java