AndroidのPair.javaから次のコードスニペットを取得しています
public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof Pair)) return false;
final Pair<F, S> other;
try {
other = (Pair<F, S>) o;
} catch (ClassCastException e) {
return false;
}
return first.equals(other.first) && second.equals(other.second);
}
instanceof
trueを返した後、ClassCastExceptionを発生させるにはどうすればよいのでしょうか。