title: Compile error at static final object inside non static inner class
body: <p>I am new to Java and reading a book for my OCJP exam. In the book its stated <em>a non static inner class can have static members only if they are declared static final</em>. But I get compile error when I try to create a <code>static final object</code> of the container class.</p>
  
  <pre><code>class Logger {
      private Logger() {
          // private constructor for singleton
      }
  
      public class LoggerHolder { // non static inner class
          public static final int x =10; // No compile here
          public static final Logger logger = new Logger();  //Compile error
      }
  
      //"The field logger cannot be declared static; static fields can only be declared in static or top //level types"
  
      public static Logger getInstance() {
          return LoggerHolder.logger;
      }
  }
  </code></pre>