title: What is the point of getters and setters?
body: <blockquote>
  <p><strong>Possible Duplicate:</strong> <br />
  <a href="https://stackoverflow.com/questions/1568091/why-use-getters-and-setters">Why use getters and setters?</a></p>
  </blockquote>
  
  <p>I have read books on Java, saying that it is good to create setters and getters for variables such as <code>x</code> and <code>y</code>.  For example:</p>
  <pre><code>public int getX(){
      return x;
  }
  
  public void setX(int x){
      this.x = x;
  }
  </code></pre>
  <p>But what is the difference from that and</p>
  <pre><code>...(shape.x)...   // Basically getX()
  </code></pre>
  <p>and</p>
  <pre><code>shape.x = 90;    // Basically setX()
  </code></pre>
  <p>If setters and getters are better, what practical problems would arise?</p>