So, suppose i have the following class:
public class Example {
public int id,
public String name,
public double value,
public int qty,
public Example(int id, String name, double value, int qty){
this.id = id;
this.name = name;
this.value = value;
this.qty = qty;
}
}
Then suppose i have the 2 objects:
Example example1 = new Example(1, "1", 1.0, 1);
Example example2 = new Example(2, "1", 2.0, 1);
How could i check for each field which are different from each other, without having to have a "if" statement for each field?
Edit: I need to save the history of the change in my database (like: "Value changed from 1.0 to 2.0"). That's why I need to check for the individual fields. And my class irl actually has a LOT more fields, and i'll need to do this for another classes as well. That's why I'm looking for something to do this programatically.