title: When to use get/set Methods in java
body: <p>I want to know when to use get and set methods(getName,setName ) in my class and when simple <code>classVariable.name = ""</code> instead <code>а = classVariable.getName()</code></p>
  
  <p>Here is example of class using set and get methods</p>
  
  <pre><code>public class ClassExampe {
  
      String name;
      String course;
  
      public String getName ( )
      {
          return name;
      }
  
      public void setName (String studentName)
      {
          name = studentName;           
      }
  
      public String getCourse ( )
      {
          return course;
      }
  
      public void setCourse (String studentCourse)
      {
          course = studentCourse;
      }
  }
  </code></pre>
  
  <p>Thanks</p>