请说出作用域public、private、protected,以及不写时的区别

不写为默认修饰符 friendly 修饰。
public:当前类、同一包中、子孙类、其他包 都可使用
protected:当前类、同一包中、子孙类 可使用
friendly:当前类、同一包中 可使用
private:仅当前类中可使用。

猜你喜欢

转载自www.cnblogs.com/remta/p/12121954.html
今日推荐