Why do we actually use getters and setters?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/565095/are-getters-and-setters-evil">Are Getters and Setters evil?</a><br>
  <a href="http://stackoverflow.com/questions/1568091/why-use-getters-and-setters">Why use getters and setters?</a>  </p>
</blockquote>



<p>I've been asking myself this for awhile but why do we actually use Getters and Setter methods? They take up extra space in our code, can someone explain. I've posted some code below for a better understanding.</p>

<pre><code>public class Test2
{
   public int _ChangeThis = 0;
}
</code></pre>

<p>--- Other way ---</p>

<pre><code>public class Test1
{
    public int _ChangeThis = 0;

    public setChangeThis(int ChangeThis)
    {
        _ChangeThis = ChangeThis;
    }
</code></pre>

<p>}</p>

<p>--- Main code ---</p>

<pre><code>Test2 testclass = new Test2();

//What is the difference and why do we use the setter? I cannot understand the advantage.
testclass.setChangeThis(1);
testclass._ChangeThis = 1;
</code></pre>
