/** * DON'T DO THIS! * Error: Method does not override method from its superclass */ @Override publicbooleanequals(Bigram b) { return first == b.first && second == b.second; }
如果插入这个注解,会发现错误信息。将其改正为:
1 2 3 4 5 6 7
@Override publicbooleanequals(Object o) { if (!(o instanceof Bigram)) returnfalse; Bigramb= (Bigram) o; return first == b.first && second == b.second; }