Lesson 20 – Static Fields & Methods

By creating instances of objects from a class blueprint, the fields and methods defined in the blueprint are considered as belonging to those instances. Simply put, each instance has its own field/method that has to be accessed through the instance it belongs to. However, sometimes it makes sense for a field or method to belong to the class itself and considered as shared across all instances. We do this by marking the field or method as “static” and then accessing it through the class name rather than any particular instance.

Members Only Content (Source Code, Quiz, Q&A)

This content is for Extended Support Package members only.
Log In Register