this is my code .....
on which basic the EQUALS method is implemented???
as my two objects the hash code is same ....but the EQUALS method returns false.
plz explain.
regards.
Code:
class Object1
{
private int data;
public Object1(int d)
{
data = d;
}
public int hashCode()
{
return 0;
}
}
class HashCodeTest
{
public static void main(String args[])
{
Object1 o1 = new Object1(100);
Object1 o2 = new Object1(200);
System.out.println("The hash code for o1: " + o1.hashCode());
System.out.println("The hash code for o2: " + o2.hashCode());
System.out.println("o1=o2: " + o1.equals(o2));
}
}
as my two objects the hash code is same ....but the EQUALS method returns false.
plz explain.
regards.
Comment