The string is 15 characters long
Remember that an object consists of both variables (state information) and methods (recipies for behavior.) Both of these are called "members" of the object. Java uses "dot notation" for both:
referenceToAnObject.memberOfObject
For example, to invoke the length()
method of the object
named str1
the following is used:
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.
The above method evaluates to an integer, 15, which is assigned to
the int
variable len
.