CHAPTER 10
STRINGS
Strings are inseparable part of computer programming. Hence, Java has provided an inbuilt class String
to handle strings. In C/C++, strings are stored in array of characters terminated by null character. In Java, we need not worry about how it is implemented internally.
10.1 Introduction
Java has a class String
defined in the package java.lang.
We are given a rich set of methods to work with strings. Table 10.1 lists the important methods for our ready reference.
It may be noted that unlike C++, strings in Java are immutable. You can not modify any character from a string.
Normal operations with strings are
- Declaring and constructing a string
- Reading a string from a console
- Writing a string to screen
- Copying one string into ...
Get Programming with Java 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.