title: Why can I change the private attribute in the class?
body: <p>I am using Java</p>
  <pre><code>public class Drink {
  
      private String contents;
  
      Drink(String theContents){
          contents = theContents;
      }
  
  
  
      public static void main(String[] args) {
          Drink water = new Drink(&quot;water&quot;);
          Drink oj = new Drink(&quot;orange juice&quot;);
          Drink cocaCola = new Drink(&quot;Coca Cola&quot;);
  
          oj.contents = &quot;not orange juice&quot;;
          System.out.println(oj.contents);
      }
  }
  </code></pre>
  <p>I thought the output should be an error.
  e.g.the line <code> oj.contents = &quot;not orange juice&quot;;</code> should produce an error.</p>
  <p>If this is wrong please tell me why :)
  thanks</p>