Increasing the scope of object from local scope
<p>I want to create an object using a method but I want it (object+reference) to live even after the method ends. Example of code:</p>

<pre><code>public class start{
public static void main (String [] Args){
  public void createObject(){
    object1 createdObject = new object1();
  }
  createObject();
  createdObject.doSomething();
 }
}

public class object1{
   //code for object 1
}
</code></pre>

<p>So my main question is: how to create object using method and let it live even after method ends. The problem is that reference <code>createdObject</code> is popped of <code>stack</code> after method ends and therefore I can't use it anymore. Is it even possible to create object for further use this way?</p>
