title: memory allocation of a variable in java?
body: <p>suppose i have a code snippet like this:-</p>
  
  <pre><code>class A {
     void help() {
        Help helper = new Help();
     }
  }
  </code></pre>
  
  <p>in the above case, the object reference helper will be allocated memory in the stack.</p>
  
  <p>now if i have a case like this </p>
  
  <pre><code>class A {
      Help helper = new Help();
  }
  </code></pre>
  
  <p>in this case, helper will not be allocated memory inside of a stack frame(I am sure of that).
  will it behave like an instance variable and will be allocated space inside of an object on heap.</p>