|
In real world, you would often see many objects of the same kind. For example, your banking example, there are likely to be many account objects for different customers. Each of these accounts has similar behavior, but their states are different from each other. The commonality between these similar objects defines the type or class of these objects. Java represents this commonality in a “class”. For example, the commonality between all the bank account objects is represented in a Account class.
|
|
A class represents a blueprint that defines the variables and the methods common to all objects of a certain kind. |
We have already seen how to define a Java class in chapter 1. You need to define the state in member variables and behavior in terms of methods.
