esse quam videri
Jump to: navigation, search


In object-oriented programming, an instance is an occurrence of an object. Each instance is unique and will have its own data. Creating an instance of an object is also known as instantiation.

Instance and object are synonymous in that they have specific values when they're created.



"Instance" emphasizes the distinct identity of the object, and instantiation is one of the core elements that make up object-oriented programming! Think of it this way - instances are the objects to which we orient our programming. Makes a lot more sense that way, huh?

Creating instances allows us to determine the behaviors of an object of the class they're created from. When you call an object in code, you can tell it to invoke one of its data variables or functions! From a programming point of view, an instance object can be a data structure, a variable or a function. It has a memory location allocated. The object is designed to be part of a class's hierarchy.

Think of a coffee shop - there are a lot of different types of coffee shops around, but they each have similar characteristics. So, let's make a COffeeShop coffee class, and create an INSTANCE object of that class:

CoffeeShop starbucks = new CoffeeShop();
CoffeeShop dunkin = new CoffeeShop();



See also


External Links