Escape Sequence
Character Escape
Octal character (ddd)
Hexadecimal Unicode character (xxxx)
Single quote
Double quote
Carriage return
New line (also known as line feed)
Form feed
The escape sequences and octal/hexadecimal notations that were defined for character
literals work the same way inside of string literals. One important thing to note about Java
strings is that they must begin and end on the same line. There is no line-continuation escape
sequence as there is in some other languages.
NOTE  As you may know, in some other languages, including C/C++, strings are implemented as
arrays of characters. However, this is not the case in Java. Strings are actually object types. As
you will see later in this topic, because Java implements strings as objects, Java includes
extensive string-handling capabilities that are both powerful and easy to use.
The variable is the basic unit of storage in a Java program. A variable is defined by the
combination of an identifier, a type, and an optional initializer. In addition, all variables have
a scope, which defines their visibility, and a lifetime. These elements are examined next.
Declaring a Variable
In Java, all variables must be declared before they can be used. The basic form of a variable
declaration is shown here:
type identifier [ = value][, identifier [= value] ...] ;
The type is one of Java's atomic types, or the name of a class or interface. (Class and
interface types are discussed later in Part I of this topic.) The identifier is the name of the
variable. You can initialize the variable by specifying an equal sign and a value. Keep in mind
that the initialization expression must result in a value of the same (or compatible) type as that
specified for the variable. To declare more than one variable of the specified type, use a comma-
separated list.
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks