Java Reference
In-Depth Information
CHAPTER 3
Strings
Strings are one of the most commonly used data types in any programming language.
They can be used for obtaining text from a keyboard, printing messages to a command-
line, and much more. Given the fact that strings are used so often, there have been many
features added to the String object over time in order to make them easier to work
with. After all, a string is an object in Java, so it contains methods that can be used to
manipulate the contents of the string. Strings are also immutable in Java, which means
that their state cannot be changed or altered. This makes them a bit different to work
with than some of the mutable, or changeable, data types. It is important to understand
how to properly make use of immutable objects, especially when attempting to change
or assign different values to them.
This chapter focuses on some of the most commonly used String methods and
techniques for working with String objects. We also cover some useful techniques
that are not inherent of String objects.
3-1. Obtaining a Subsection of a String
Problem
You would like to retrieve a portion of a string.
Solution
Search WWH ::




Custom Search