Java Reference
In-Depth Information
String Literals
Java supports one other type of literal: the string. A string is a set of characters enclosed by
double quotes. For example,
is a string. You have seen examples of strings in many of the println( ) statements in the
preceding sample programs.
In addition to normal characters, a string literal can also contain one or more of the es-
cape sequences just described. For example, consider the following program. It uses the \n
and \t escape sequences.
The output is shown here:
Ask the Expert
Q :
Is a string consisting of a single character the same as a character literal? For
example, is "k" the same as 'k'?
Search WWH ::




Custom Search