Java Reference
In-Depth Information
The output from the program is shown here:
One other point about the preceding example: As mentioned, sqrt( ) is a member of the
standard Math class. Notice how sqrt( ) is called; it is preceded by the name Math . This is
similar to the way System.out precedes println( ) . Although not all standard methods are
called by specifying their class name first, several are.
Characters
In Java, characters are not 8-bit quantities like they are in many other computer languages.
Instead, Java uses Unicode. Unicode defines a character set that can represent all of the
characters found in all human languages. In Java, char is an unsigned 16-bit type having
a range of 0 to 65,536. The standard 8-bit ASCII character set is a subset of Unicode and
ranges from 0 to 127. Thus, the ASCII characters are still valid Java characters.
A character variable can be assigned a value by enclosing the character in single quotes.
For example, this assigns the variable ch the letter X:
Search WWH ::




Custom Search