Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 국제화
- OGNL
- 생성자
- 에러페이지
- Eclips
- mybatis
- 안드로이드
- 기본
- struts2
- layout
- 예외처리
- 어노테이션
- Graphic
- AWT
- Menu
- JavaScript
- Java
- Android
- 오버로딩
- Spring
- HTML
- paint
- 메소드
- 전화걸기
- 메서드
- JSP
- oracle
- 이클립스
- 배열
- 클래스
Archives
- Today
- Total
note
super로 은닉된 슈퍼클래스의 멤버변수 접근하기 본문
package com.over2;//super로 은닉된 슈퍼클래스의 멤버변수 접근하기
class Point2D{
protected int x=10; //은닉 변수
protected int y=20; //혹은 쉐도우 변수
}
class Point3D extends Point2D{
protected int x=40; //슈퍼 클래스에 존재하는 멤버변수를
protected int y=50; //서브 클래스에 다시 한번 정의함
protected int z=30;
public void print(){
System.out.println(x+", "+y+", "+z);
}
public void print02(){
System.out.println(super.x+", "+super.y+", "+z);
}
}
public class SuperTest04 {
public static void main(String[] args){
Point3D pt = new Point3D();
pt.print();
pt.print02();
}
}
40, 50, 30
10, 20, 30
'자바 > 오버라이딩' 카테고리의 다른 글
super 연습문제 (에러 찾기) (0) | 2011.12.20 |
---|---|
Super 기본 정수 (0) | 2011.12.20 |
메소드 오버라이딩 super 참조 변수 (0) | 2011.12.20 |
메소드 오버라이딩 (0) | 2011.12.20 |