Calling super()

If you provide a class like this:

public class Foo
{
}

or this:

public class Foo()
{
    public Foo()
    {
    }
}

the compiler will generate code for this:

public class Foo()
{
    public Foo()
    {
        super();
    }
}

So, strictly speaking, the call to “super()” is always there.

In practice you should only call “super(…)” where there are parameters you want to pass to the parent constructor.

It isn’t wrong to call “super()” (with no parameters) but people will laugh at you 🙂

Leave a Comment