public class Pparent{
int p;
}
public class Raw1 extends Pparent {
int c;
Raw1(int c, int p){
this.c = c;
this.p = p;//
System.out.println(this.p);
System.out.println(this.c);
System.out.println(super.p);
//super.p = p;//
System.out.println(this.p);
// so can we say that only reference of parent class is getting inside child class
}
public static void main(String[] args) {
Raw1 rrr = new Raw1(1,20);
Pparent ppp = new Pparent();
System.out.println(ppp.p);
System.out.println(rrr.p);
}
}
здесь, в третьей строке, когда я печатаю значение переменной super.p, она печатается как 20. но я не инициализирую значение super.p, я просто инициализировал значение this.p, поэтомуя должен получить значение как 0, но я получаю значение как 20. кто-нибудь может объяснить, пожалуйста, как !!! 1