O'Reilly logo

Programming with Java by Sunil Patekar, Mahesh Bhave

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

  1. Declaring and constructing a string
  2. Reading a string from a console
  3. Writing a string to screen
  4. Copying one string into ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required