title: Why am i not able to print variable value directly in main method which is declared in class above main method?
body: <p><strong>Why static variable value been allowed to print directly in main method, while to print normal integer type value, it requires to creation of object.</strong></p>
  
  <ul>
  <li>although that is global, but x is also being accessed in same class then why i can't directly access that.  </li>
  </ul>
  
  <p>While answering,  please cover memory allocation part. </p>
  
  <p>From my understanding </p>
  
  <blockquote>
    <p>static, as it is global variable stored on permanent generation, then what about this primitive int x, is this not allocated on private stack? Please assist.</p>
  </blockquote>
  
  <pre><code>  public class Test{
  
      int x = 7;
      static int y = 10;
  
      public static void main(String[] args) {
  
          System.out.println("the value of y "+ y);
  
          //compile error on sysout for value x like this,
          //System.out.println("the value of x "+ x);
  
         //While in this way i am able to print x, why?
  
          Test test= new Test();
          System.out.println("the value of x "+test.x);
  
      }
  
  }
  </code></pre>
  
  <p><strong><em>Please assist on memory allocation of program, Thanks in advance!</em></strong></p>