public class Employee {
int id;
String value;
@Override
public boolean equals(Object obj) {
return true; }
@Override
public int hashCode() {
System.out.println("hi this is my hashcode " + this.hashCode());
return this.hashCode();}
}
public class TestCH {
public static void main(String args[])
{
Employee emp1= new Employee();
Employee emp2= new Employee();
Employee emp3= new Employee();
Employee emp4= new Employee();
Map map= new HashMap();
map.put( emp1,1);
map.put(emp2,2);
map.put(emp3,3);
System.out.println("with map "+map.size());
}
}
in this code i'm trying to print hashcode through System.out.println is generating the StackOverflowError. why i'm getting StackOverflowError Thank you