This(); Statement In Java | What Is The Use Of This(); Statement In Java - Math Traders

Latest

This(); Statement In Java | What Is The Use Of This(); Statement In Java

                                 This(): statement  

This(): statement is used to

achieve constructor chaining within the class

 

Use of this(); statement:

        1. It is used to achieve constructor chaining within the class.
2. It should be the first statement of the constructor body.
3. It must be declared inside the constructor body only. We can't declare anywhere else(              like method or block)
4. Multiple this(); statements are not allowed.
**Note : At a time this() and super() are not allowed  

 


No comments:

Post a Comment