title: Why can we create an instance of a class inside a static method?
body: <p>I have never really understood why code such as that given below is valid and would really appreciate it if someone helped me out.</p>
  
  <pre><code>public class A{
  
      int x;
      int y; 
  
      void hello() {
          System.out.println("Hello World");
      }
  
      public static void main(String[] args) {
          A my_instance = new A();
  
          my_instance.hello();
      }
  }
  </code></pre>
  
  <p>OUTPUT:</p>
  
  <pre><code>Hello World
  </code></pre>
  
  <p><strong>Question: Why are we allowed to create an instance of A inside one of its own static methods?</strong> </p>
  
  <p>I understand that static methods belong to the class and not any particular instance, but does this mean that under the hood the compiler first analyzes everything that's not static and makes that code available to static methods? </p>