• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Lesson 7. Creating Custom Classes > Classes, Top-Level Classes, and Instances

Classes, Top-Level Classes, and Instances

Basically, a class is a definition or blueprint of how an object is made up and how it should act. For example, an instance of the Array class (an Array object) can store multiple pieces of information in numerically indexed locations (myArray[0], myArray[1], myArray[2], and so on). How can the array do this? It knows how to do this because it was defined that way by the Array class. The Array class has hidden logic and definitions (code) that work behind the scenes to define the way an Array object works and how it's used. Think of a class as a template from which objects are created. This is a vague description of a class, but as you progress through this lesson and are introduced to more concepts, terminology, and examples, you'll gain a better understanding of what a class really is.

A class generally exists to produce an instance of itself on demand. You create an instance of a class by invoking the constructor method of that class. For example:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint