Strings

From a day-to-day programming standpoint, one of the most important of Java’s data types is String. String defines and supports character strings. In many other programming languages a string is an array of characters. This is not the case with Java. In Java, strings are objects.

Actually, you have been using the String class since Chapter 1, but you did not know it. When you create a string literal, you are actually creating a String object. For example, in the statement

Image

the string “In Java, strings are objects.” is automatically made into a String object by Java. Thus, the use of the String class has been “below the surface” in the ...

Get Java, A Beginner's Guide, 5th Edition, 5th 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.