在我贡献的两个项目中,我遇到了这个错误:
FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: java.util.Objects
Run Code Online (Sandbox Code Playgroud)
那是因为我已经实现hashCode
和equals
使用方法Objects
的类.
@Override
public int hashCode() {
int hash = 7;
hash = 97 * hash + Objects.hashCode(this.image);
hash = 97 * hash + Objects.hashCode(this.car);
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final SummaryContent other = (SummaryContent) obj;
if (!Objects.equals(this.image, other.image)) {
return false;
}
return Objects.equals(this.car, other.car);
}
Run Code Online (Sandbox Code Playgroud)
当我编译时,我不会收到错误或警告.为什么会发生这种情况?
归档时间: |
|
查看次数: |
2311 次 |
最近记录: |