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.
}
}
From the comment in the code, my question is actually how to uniquely identify reference itself, like address in C.
There is nothing you need to do here, the Node already has the default implementation which returns a hash code based on the memory location it resides at.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With