title: What is the recommended/correct way to access fields in an inner class?
body: <p>Suppose we have this class and its inner class:</p>
  
  <pre><code>/* Outer.java */
  public class Outer {
      private static class Inner {
          private final Object foo;
  
          public Inner(Object foo) {
              this.foo = foo;
          }
  
          public Object getFoo() {
              return foo;
          }
      }
  
      Inner inner = parse(/* someMistery */);
  
      // Question: to access foo, which is recommended?
      Object bar = inner.getFoo();
      Object baz = inner.foo;
  }
  </code></pre>
  
  <p>I am surprised that <code>inner.foo</code> works. </p>
  
  <p>Since <code>foo</code> is <code>private</code>, it can be accessed <strong>only</strong> through <code>getFoo()</code>, right?</p>