Could you explain in details?
It's give some kind of unknown exception.
There's no unknown exception. A complete stack trace of the exception should be output.
instead of it dispaly null , 0 (nul for instance t(Object) and 0 for i)
Again, you are calling the Test constructor recursively. Take a look at that (ugly) diagram to see what's happening. You're creating new Test instances from the Test constructor. It will loop endlessly.
Exception in thread "main" java.lang.StackOverflowError
at sun.nio.cs.SingleByteEncoder.encodeArrayLoop(Unknown Source)
.......... It's going on....
Christophe Verré wrote:What kind of exception ? StackOverflowError ? Which would not be surprising because you are recursively calling the Test constructor from the Test constructor. It's calling it again and again...
he is right then. You are call the constructor recursively that's why your program is throwing this exception.
remove t = new Test(); from constructor & your code will work without any error