Access specifiers: public and private data and methods
Learn how to use the keywords public and private, and how to use getter and setter methods to maintain consistent object state.
Instance variables of an object can be accessed using dot notation, just like in Python, Javascript, or C++. Here’s the simple example of defining a Circle
class, which allows Circle
objects to be created. Each circle object has the instance variables x
, y
, and r
:
Get hands-on with 1400+ tech skills courses.