Next page | Contents page |

OO = Object Oriented

Objects are a way of wrapping up everything to do with a particular kind of entity, so they are self-contained and can have no side effects.

A class is a recipe for making objects with an identical structure.

Objects are instances of classes.

To get the most benefit from using Java you really should make the most of its OO capabilities. Design all your programs in an OO way. (UML, Unified Modelling Language, provides tools to help with OO design and implementation. Unfortunately the implementations of the tools tend to be expensive. Nevertheless, the concepts are freely available and useful. On this page we use, loosely, UML class diagrams.)

Instances of the class:

How we create the instances in Java:

	Customer customer1 = new Customer ("John", "Smith", "ABC123");
	Customer customer2 = new Customer ("Jane", "Jones", "XYZ789");

Notice the keyword new. That seems to be followed by a method call but as the "method" has the same name as the class it is actually a special thing called a constructor. Constructors are written like methods except that they have no return type (not even void) and they have the same name as the class (including the capital first letter).

In Java there is no explicit way to delete an object again. The JVM works out when objects are no longer needed. It periodically performs a background process called "garbage collection".

Next page | Contents page |