title: Confused with Java Encapsulation Concept
body: <p>Good day!</p>
  
  <p>I am reading a Java book about encapsulation and it mentioned the getter and setter method.</p>
  
  <p>I've read that to hide the attributes, I must mark my instance variables as <strong>"PRIVATE"</strong> and make a <strong>"PUBLIC"</strong> method of <code>getter and setter</code> to access the data. So I tried making a similar but not the conventional code about it as follows:</p>
  
  <pre><code>public class AddressBookEntry {
  
      private String name;
      private String address;
      private String telNo;
      private String email;
  
      public void getAllInfo() {
          name = JOptionPane.showInputDialog("Enter Name: ");
          address = JOptionPane.showInputDialog("Enter Address: ");
          telNo = JOptionPane.showInputDialog("Enter Tel. No: ");
          email = JOptionPane.showInputDialog("Enter Email Address: ");
      }
  }
  </code></pre>
  
  <p>Does my code above exposes my variables because I assigned it directly? How can I do this better? Would it be better if I make the conventional <code>getter and setter</code> method instead and assigned the values on the other class? What does "hiding the data" means?</p>
  
  <p>Thank you.</p>