Java Reference
In-Depth Information
Returns a
String
with each character converted to its lower-
case equivalent if it has one according to the specified locale.
public String
toUpperCase(Locale loc)
Returns a
String
with each character converted to its upper-
case equivalent if it has one according to the specified locale.
The
concat
method returns a new string that is equivalent to the string
returned when you use
+
on two strings. The following two statements
are equivalent:
newStr = oldStr.concat(" not");
newStr = oldStr + " not";
Exercise 13.3:
As shown, the
delimitedString
method assumes only
one such string per input string. Write a version that will pull out all the
delimited strings and return an array.
Exercise 13.4:
Write a program to read an input string with lines of
the form "
type value
", where
type
is one of the wrapper class names
(
Boolean
,
Character
, and so on) and
value
is a string that the type's con-
structor can decode. For each such entry, create an object of that type
Display the final result when all the lines have been read. Assume a line
is ended simply by the newline character
'\n'
.
13.2.5. String Conversions
You often need to convert strings to and from something else, such as
integers or booleans. The convention is that the type being converted
to
has the method that does the conversion. For example, converting from
a
String
to an
int
requires a static method in class
Integer
. This table
shows all the types that you can convert, and how to convert each to
and from a
String
: