Skip to main content
Logo image

Chapter 7 Strings

Like arrays and the rest of the data types we will learn about from here on out, the String datatype is a reference type. However, unlike arrays, but like most other reference types in Java, String is defined by a class. Classes are a critical part of Java and we’ll discuss them in depth starting in Chapter 8 Classes. But first we’re going to fill in some more details we need to know about how to use String values to represent and manipulate text.
It also makes sense to look at String on its own before we get to classes more generally since it’s a special class that gets a bit of extra love from Java. For one thing it’s one of the handful of classes in the java.lang package which means its available by default in all Java programs. But it is also special in that it is the only class in Java that supports an operator other than == and !=, namely the + string concatenation operator. And it’s the only class in Java with a literal value syntax that lets us write String values in our programs like "hello, world!".