eclipse中不能自动添加Source 的get和set方法还有hashCode 之类的方法,是我缺少东西嘛

2020-10-28 教育 77阅读

hashCode and equals methods are belonging to a concrete object and need members belonging to the object to compute any meaningful value.

Eg. if you want to compare two instances of the same class, you do that by comparing their "computed values" through their equals and/or hashCode methods.

Static methods and members belong to the class and not to the concrete instance uniquely.

大概的意思就是必须有非静态的成员变量,才能作比较,而作比较就得调用那个它们的equals,比较他们的hashCode这些。总而言之,言而总之,你的这个java文件的这个类必须有

public String name;

这种定义,不然不能帮你自动生成出来。()

声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com