The string is 15 characters long
An object consists of both variables (state information) and methods (small programs). Both of these are called members of the object.
To access the members of an object use dot notation :
referenceToAnObject.memberOfObject
For example, to invoke the length()
method of the object
named str1
do this:
str1.length();
To store the value computed by the length method in a variable, do this:
len = str1.length();
Method names have ()
at their end.
Often there is additional information inside the ()
,
but they are required even if they contain nothing.
(Thought Question:) Is it possible for a program to have several objects all of the same class?