I have two java objects and I want to merge them into single object. Problem is the two objects does not contain plain primitive type properties(fields) they contain complex
Field[] fields = YourClass.getFields();
for (Field field : fields) {
// get value
YourObject value = field.get(objectInstance);
// check the values are different, then update
field.set(objetInstance, value);
}