I am just learning and would like to know about a piece of code that sets the object variable.
What is the correct way to set object variable bfield in the follwoing test class?
public class test {
private String afield;
private String bfield;
public test() {
buildList();
}
public void buildList() {
some code to derive and populate afield.
this.bfield = this.afield; // ( 1)
setBfield(afield); // (2) say getter and setters do exist
bfield = afield; // (3)
}
What is the right way to do? I soption 1 OK or option 2?