can you give me example how to update values in one object by another object of same type? For example here is my class:
public class MyObj {
private int id;
private String name;
private String phone;
private String address;
// some getters and settters ...
}
And I have another class with that stuff:
private ArrayList<MyObj> objectsList; // list of some objects
public MyObj update ( MyObj newObj ) {
// here I need set new values of properties of newObj to object with same id property in objectsList;
}
Exist some way how to do that without manually setting up all properties?
MyObjand use it whenever you need to create a dup. This approach also avoids potential concurrency issues which you might encounter while "updating" an object field-by-field, since now all you're doing is reference assignment which is an atomic operation.