Strings and Object References in Java

The String class is used for text manipulation. As you read, you will learn different ways to create Strings, methods to manipulate Strings, the String concatenation operator '+', and about how Strings are immutable.

1. Strings and Object References

In previous chapters, methods were called with parameters that were primitive data types. This chapter discusses how to use object references as parameters. The class String is used in many examples.

Students taking the computer science Advanced Placement examination are expected to be familiar with the String class.

Chapter Topics:

      • String literals
      • The null value
      • More about garbage
      • The String class
      • String concatenation
      • Strings are immutable
      • Cascading methods
      • Some String methods
        • concat()
        • length()
        • trim()
        • substring()
        • toLowerCase()
        • startsWith()
        • charAt()

Question 1:

(Review:) What TWO things does the following statement do?

    String zeta = new String( "The last rose of summer" );

Source: Bradley Kjell, http://programmedlessons.org/Java9/chap44/ch44_01.html
Creative Commons License This work is licensed under a Creative Commons Attribution-NonCommercial 3.0 License.