It would be nice if different objects printed different things.
If different instances (different objects)
of the HelloObject
class
print different strings,
then each instance must have its own data,
which must be initialized.
The class definition needs a constructor.
Here is what a class definition usually looks like:
class ClassName { Description of the variables. Description of the constructors. Description of the methods. }
Important: An object's methods use that object's instance variables. Remember that an object has identity, state, and behavior. "Identity" means that each object has its own variables. The "state" of an object is the values held in its variables. The "behavior" of an object is its methods, which use the object's own variables.
If each instance of HelloObject
has
its own message,
where is that message kept?