Because to create the instance of it, you will need to create the variable, which is itself an instance of it - which will invoke the constructor.
This will result in infinite recursive call to the constructor.
Assume class A
has an instance variable named a
:
Invoking the constructor of A
will cause the initialization of a
, which is itself an A
. To do it - the constructor of A
will be invoked again.
Note that it will not even compile because the compiler cannot allocate the memory for it, it doesn't know how much space to allocate for each object. How much space does it take to store the instance variable a
? [Any finite space will not be enough because there will always be an extra variable which also needs to be allocated]