LoginSignup
0
0

More than 3 years have passed since last update.

Javaのprotected

Posted at

protected

ゲッター・セッターとはまた違う方法です。
クラス外から呼び出したいときは、private(クラス外は呼び出せない)では呼び出せないので、「protected」を使って、クラス内とサブクラスからのみアクセスを許すフィールドを作ります。
「public」「protected」「private」の3つのアクセス権です。
・public: どこからでもアクセス可能
・protected: そのクラスと子クラス内からのみアクセス可能
・private: そのクラス内からのみアクセス可能

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0