Java objects created inside main method and created outside main
<p>//Test.java</p>

<pre><code>class Example {

     public int size = 5;
}

public class Test{

   public static void main(String[] args) {
        Example eg =  new Example();
        System.out.printlin(eg.size);
     }

}
</code></pre>

<p>//Person.java</p>

<pre><code>public class Person {

public Person(){

 private Test ex = new Test();
 System.out.println(ex.size);

}

}
</code></pre>

<p>Person.java will not give me any output but my question is where all i can create a object.
    For eg: Here I've created in constructor,in above Test class, I've created in main() method.</p>

<p>In Person class,if I've a main method for eg, like below</p>

<pre><code>public static void main(String[] args) {

 private Test ex = new Test(); //If i use private ecllipse is showing error, Why is it ?
 System.out.println( ex.size); //This is also showing as error
 I've created a object for Test class so i can access it objects here right.
}
</code></pre>

<p>Thanks</p>
