目录
super 代表父类的引用, 用于访问父类的属性、 方法、 构造器
访问父类的属性,但不能访问父类的private属性
例子:
父类
- package com.hspedu.super_;
-
- public class A {
- public int n1 = 100;
- protected int n2 = 200;
- int n3 = 300;
- private int n4 = 400;
-
-
- //访问父类的属性,但不能访问父类的private属性
- public void test100(){
-
- }
- protected void test200(){
-
- }
- void test300(){
-
- }
- private void test400(){
-
- }
- }
子类