title: Java - Anonymous class are static or not
body: <p>I know it depends on the context in which the anonymous class has been written (static or non static method).
  but look this part of code:</p>
  
  <pre><code>public class A {
      int fieldOfA;
  
      private static class B {
          int fieldOfB;
      }
  
      public static void main(String[] args) {
  
          B obj = new B() { //this anonymous class is static becuase is in the main method.
  
              private static void testMethod() { //so why here i have an error and i can put just a non-static method
                                                 //if my class is static ?
                                                 //a class static can have static method, but this class no, why?
              }
          };
      }
  }
  </code></pre>
  
  <p>it's sure that anonymous class are static?</p>