title: Java setting private fields inside constructors
body: <p>Common design practice is to make instance variables private and have public getters and setters to access them. But many times I have seen code samples on the internet that have constructors that assign values directly to the private instance variable instead of using the setters inside constructors. Am I missing something?</p>
  
  <pre><code>public class Person{
      private String name;
  
      public Person(String name){
          //is this right, seems like the whole encapsulation purpose is defeated
          this.name = name;
  
          //shouldn't this be used
          setName(name);
      }
  
      public String getName(){
          return this.name;
      }
  
      public void setName(String name){
          this.name = name;
      }
  }
  </code></pre>