Strings and Object References in Java
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
concatenationString
s 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 This work is licensed under a Creative Commons Attribution-NonCommercial 3.0 License.