Self-Review Exercises

14.1 State whether each of the following is true or false. If false, explain why.

a) When String objects are compared using ==, the result is true if the Strings contain the same values.

b) A String can be modified after it’s created.

14.2 For each of the following, write a single statement that performs the indicated task:

a) Compare the string in s1 to the string in s2 for equality of contents.

b) Append the string s2 to the string s1, using +=.

c) Determine the length of the string in s1.

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.