How is it possible to create object in Class definition itself?
<p>I have some doubt on how this works, consider a simple Java program:</p>

<pre><code>package com.example;

public class Test {

    public static void main(String[] args) {

        Test t = new Test();  (1) &lt;---- How is this possible
        t.print();
    }

    public void print() {
        System.out.println("This is demo");
    }
}
</code></pre>

<p>This is pretty straightforward program.</p>

<p>However, I have doubt at (1). We are creating an instance of Test, but this is still in the definition of Class Test. How is this possible?</p>

<p>Any explanation to help this would be great.</p>