I have a requirement to fetch values from
Map<Object1, Object2>() objectMap= new HashMap<Object1, Object2>();
Object1 obj1 = new Object1();
Object2 obj2 = new Object2();
//Object1 class:
public class Object1{
private String name;
private String id;
private String number;
//along with getters and setters
}
//Object2 class:
public class Object2{
private String value1;
private String value2;
//along with getters and settersenter code here
}
objectMap.put(obj1, obj2);
Object1 obj3 = new Object1();
obj3 has values same as obj1, i.e all the fields, name, value and number as the same for obj3.
I need to fetch value of map using obj3 if obj1 equals obj3. How do I check obj1 equals to obj3 and then how do I fetch map value using obj3?