NodeLink link = null; for(int i = 0; i < links.size(); i++){link = (NodeLink)links.elementAt(i);if( this.hashCode() < node.hashCode() ){if( link.node1 == this && link.node2 == node )break;}else{if( link.node2 == this && link.node1 == node )break;}link = null;}
HashCode() is explicitly used in methods where hash functions are used, like hashTable() etc.One should always override hashCode() when overriding equals(). Unexpected behaviour will occur if you don't do so.HashCode() should have the same value whenever equals() returns true.