I'm currently learning about class inheritance in my Java course and I don't understand when to use the super()
call?
Edit:
I found this example of code where super.variable
is used:
class A
{
int k = 10;
}
class Test extends A
{
public void m() {
System.out.println(super.k);
}
}
So I understand that here, you must use super
to access the k
variable in the super-class. However, in any other case, what does super();
do? On its own?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…