[Java] Java protected

less than 1 minute read

protected

It’s a different method than the getter/setter. When you want to call from outside the class, you can not call it private (you can not call outside the class), so use “protected” to create a field that is accessible only from within the class and subclasses. The three access rights are “public”, “protected”, and “private”. ・Public: accessible from anywhere ・Protected: Can be accessed only from within the class and child classes Private: accessible only from within the class

Tags:

Updated: