Why the compiler doesn't complain about this error ?

Posted by M.H on Stack Overflow See other posts from Stack Overflow or by M.H
Published on 2010-05-23T17:26:51Z Indexed on 2010/05/23 17:30 UTC
Read the original article Hit count: 220

Filed under:
|

Hi
I am writing some java questions to help my friends in the java exam. I wrote a question and I supposed that three errors will occurred in the code but the compiler complained only about two. the code is :

class MyClass 
{ 
   static MyClass() 
    {  
     System.out.println("I am The First Statement here!"); 
       this();  
    } 
} 

I expected the following errors :

  1. the constructor can't be static

  2. this can't be in a static function (since the constructor isn't valid)

  3. this here should be the first statement.

NetBeans isn't complaining about the second error here. why ?

© Stack Overflow or respective owner

Related posts about java

Related posts about netbeans