
The length method is called using a String object reference and the dot
operator, as illustrated in lines 21, 24, and 29 of Example 3.6. At lines 21
and 29, the length method is called inside an output statement and the
respective return values from the length method are output. At line 24, we
call the length method for the greeting2 object and assign the return value
to the int variable len. Then at line 25, we output the value of the variable
len. As shown in Figure 3.11, the length of “Hi” is 2, the length of “Hello” is
5, and the length of the empty String is 0.
The toUpperCase and toLowerCase Methods
The toUpperCase method converts all the letters ...