Hi! I wonder why we have to use setter and getter methods to define sth? : ***Using Setter and Getter**

    class sum {
      int a;
      int b;
      int c;
      public void setSum(int a, int b) {
        c = a + b;
      } 
      public int getSum() {
        return c;
        }
      public static void main(String[] args) {
        sum s = new sum();
        s.setSum(10,7);
        System.out.println("Sum: " + s.getSum());
        }
      }

***Using just only one method (getter)**

    class sum1 {
      int a;
      int b;
      int c;
      public int getSum(int a, int b) {
        c = a+b;
        return c;
        }
      public static void main(String[] args) {
        sum1 s1 = new sum1();
        System.out.println("Sum: " + s1.getSum(7,10));
        }
      }

**I would like to know why the teacher encouraged me to use Setter and Getter when both coding ways result the same (17)....I am new to Java and want to ask you guys what specific reason lies behind using Setter and Getter! Thank you so much~**
