易百教程

71、能在构造函数中同时使用 this()super() 吗?

不能。因为 this()super() 必须是类构造函数中的第一条语句。

例子:

public class Test{  
    Test()  
     {  
         super();   
         this();  
         System.out.println("Test class object is created");  
     }  
     public static void main(String []args){  
     Test t = new Test();  
     }  
}

运行错误:

Test.java:5: error: call to this must be first statement in constructor