Hel*_*ang 2 java reference hashcode
public class Node {
private Node nextNode;
@Override
public int hashCode() {
//How to implement this?
//Because you just have a attribute which is a reference.
//I think the attribute is almost useless, because if you use the HashCode of the attribute, you will finally fall into a useless loop.
//Thus, I think you should find a way to represent the HashCode of reference (instance) itself.
}
}
Run Code Online (Sandbox Code Playgroud)
从代码中的注释,我的问题实际上是如何唯一地标识引用本身,如C中的地址.
| 归档时间: |
|
| 查看次数: |
547 次 |
| 最近记录: |