0
点赞
收藏
分享

微信扫一扫

RestrictVisit


package com.shrimpking.t2;

/**
 * Created by IntelliJ IDEA.
 *
 * @Author : Shrimpking
 * @create 2024/9/16 21:10
 */
class Person7{
    //私有属性
    private String name;
    private int age;

}

class Student7 extends Person7{
    //在这里访问父类的私有属性
    public void setVar(){
//        super.name = "zhang"; //不可访问
//        super.age = 25; //不可访问
    }
}

public class RestrictVisit
{
    public static void main(String[] args)
    {
        new Student7().setVar();
    }
}

举报
0 条评论