title: Java code - how to set object variable
body: <p>I am just learning and would like to know about a piece of code that sets the object variable.</p>
  
  <p>What is the correct way to set object variable bfield in the follwoing test class?</p>
  
  <pre><code>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)
  }
  </code></pre>
  
  <p>What is the right way to do? I soption 1 OK or option 2?</p>