The code below fails to compile:
class Super
{
int i = 0;
Super(String text)
{
i = 1;
}
}
class Sub extends Super
{
Sub(String text)
{
------------LINE 14------------
i = 2;
}
public static void main(String args[])
{
Sub sub = new Sub("Hello");
System.out.println(sub.i);
}
}
But when I'm adding super(text)
at line 14, it's working fine. Why is it so?