title: Speed optimizing: private and public variables - Java
body: <p>I am asking this question purely for the speed aspects of the question.</p>
  
  <p>What is the difference in speed between getting the value from an object when it is private or public (Java)?</p>
  
  <pre><code>class MyClass {
      public int myInt = 5;
  }
  class MyOtherClass {
      private int myInt = 5;
  
      public int getMyInt() {
          return myInt;
      }
  }
  class MyMainClass {
      public static void main (String [] args) {
          MyClass myObject = new MyClass();
          MyOtherClass myOtherObject = new MyOtherClass();
  
          // which is faster?
          System.out.println(myObject.myInt);
          System.out.println(myOtherObject.getMyInt ());
      }
  }
  </code></pre>
  
  <p>I know I can test it, but if anyone alreay knows it, it can't hurt :)
  Thanks in advance!</p>