java.lang.String
To complete this chapter, here is the standard Java class java.lang.String. That's obviously a class type, contrasting with the primitive types with which we started the chapter. You will use String instances a lot—whenever you want to store some characters in a sequence or do human-readable I/O.
As the name suggests, String objects hold a series of adjacent characters, similar to an array. Strings have methods to extract substrings, to put into lower case, to search a String, to compare two Strings, and so on. Arrays of char have none of these. String is a very convenient class and you'll use it extensively in many programs.
literals: A string literal is zero or more characters enclosed in double quotes, like these two ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access