Access Modifiers
public
, private
, and protected
are the three access modifiers used in class to control its access from the outside. By default, all members (properties, fields, methods, or functions) are publicly accessible from outside the class.
private
members can access only internally within the class and cannot be accessible from outside. Private should start with #
.
protected
fields are accessible only from inside the class and those extending it. These are useful for the internal interface as the inheriting class also gains access to the parent class. Protected fields with _
.
Last updated
Was this helpful?