super

java/객체지향

[객체지향] super와 super()

●참조변수 super super는 자손 클래스에서 조상 클래스로부터 상속받을 때, 상속받은 멤버와 자손클래스의 멤버가 같은 경우 구별하기 위해 사용한다. 구별하기위해 사용한다는 점에서 멤버변수와 지역변수를 구별 할 때 사용했던 'this'와 쓰임이 비슷하지만, 참조변수 super는 자손 클래스와 조상 클래스의 멤버를 구별 했다는 점에서 this와 차이가 있다. class Ex7_2 { public static void main(String args[]) { Child c = new Child(); c.method(); } } class Parent { int x = 10; /* super.x */ } class Child extends Parent { int x = 20; // this.x void me..

각시탈코더
'super' 태그의 글 목록