Sunday, December 11, 2011

Designing a class 2: Instances

Classes are considered a blueprints of concepts. To realize the blueprints, we have to create an instance of a class. Like a blueprint, a blueprint can be used for several realizations.

Realization can be done by using “new” keyword.

Employee alice = new Employee();

Employee bob= new Employee();

Here the blueprint Employee has been realized as alice and bob. Or we can say, class Employee has been instantiated as alice and bob.

When creating instances of class, they are linked with their own memory allocation of Fields (Member variables) so that data of each instance are isolated from other instances.

No comments:

Post a Comment