My footsteps
참조변수 Super 본문
728x90
public class Over {
public static void main(String[] args) {
Child C = new Child();
C.String();
}
}
class Parent {
int x = 10;
}
class Child extends Parent{
int x = 20;
void String() { //굳이 매서드를 만들어서 main매서드 에서 호출하는 이유는,main"매서드"이기 때문에 class는 직접호출할수없다.
System.out.println("this.x = "+this.x);
System.out.println("super.x = "+super.x);
}
}
728x90