title: What is the role of getter / setter in encapsulation?
body: <p>As per my knowledge, encapsulation hides your data member from an outsider and only allows it access using methods of the same class. So that they're not able to show your personal data to outsiders. Following way it's true,</p>
  <pre><code>private double amount;
  
  public void add(double value) {
      return this.amount + value;
  }
  </code></pre>
  <p>Here your amount variable doesn't share with outsiders using private and they don't know about the variable name you used.</p>
  <p><strong>But in similar case we also provide getter / setter for access them so how can encapsulation become secure from outsiders?</strong></p>
  <pre><code>public void setAmount(double value) {
      this.amount = value;
  }
  
  public double getAmount() {
      return this.amount;
  }
  </code></pre>
  <p>This means most probably getter or setter method has the same pattern and outsider which has a basic knowledge about this. So I suppose after doing some attempt he is able to get using getter or change using setter. In such case, defining amount directly public or providing getter both becomes the same.</p>
  <p>Can someone explain it?</p>