Why does the super keyword not showing error though not given in first line
It does for me:
class Superclass
{
}
class Subclass extends Superclass
{
Subclass()
{
System.out.println();
super();
}
}
Compiling gives an error of:
Test.java:10: call to super must be first statement in constructor
super();
^
1 error
Please show a similar short but complete program with it not giving an error. Note that I'm assuming you really have got super();
rather than, say, super.foo();
which is just a call to the superclass implementation of foo();
and can appear anywhere in a method or constructor.