Constructor (object-oriented programming): Difference between revisions

Content deleted Content added
No edit summary
Tag: Newer user possibly adding unreferenced or improperly referenced material
Line 116:
# Initialize member variables to the specified values.
# Executes the body of the constructor.
 
#Java permit users to call one constructor in another constructor using <code>this()</code> keyword.
But <code>this()</code> must be first statement.
<source lang="java">
class Example
{
Example()
{
this(1);
System.out.println("0-arg-cons");
}
Example(int a)
{
System.out.println("1-arg-cons");
}
public static void main(String[] args)
{
Example e= new Example();
}
</source>
 
 
Java provides access to the [[superclass (computer science)|superclass's]] constructor through the <code>super</code> keyword.