We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
set.remove(p3); //此时remove不掉,造成内存泄漏 原文在这里https://github.com/francistao/LearningNotes/blob/master/Part1/Android/Android%E5%86%85%E5%AD%98%E6%B3%84%E6%BC%8F%E6%80%BB%E7%BB%93.md
The text was updated successfully, but these errors were encountered:
@bbfxier
@Override public int hashCode() { return Objects.hash(name, pwd, age); }
Person类重写了hashCode方法的话会重现。因为HashSet会根据气hashCode来判断是提取set中的元素。而这个值是add时候的值,在p3的成员变量改变后hashCode就变了.
Sorry, something went wrong.
正常情况下 修改对象内部变量 不会改变hashCode啊 所以也不会remove不掉啊
No branches or pull requests
set.remove(p3); //此时remove不掉,造成内存泄漏
原文在这里https://github.com/francistao/LearningNotes/blob/master/Part1/Android/Android%E5%86%85%E5%AD%98%E6%B3%84%E6%BC%8F%E6%80%BB%E7%BB%93.md
The text was updated successfully, but these errors were encountered: