Java Reference
In-Depth Information
SR 3.7
The output produced is:
o
Found
11
5
SR 3.8
The following statement prints the value of a
String
object in all upper-
case letters:
System.out.println (title.toUpperCase());
SR 3.9
The following declaration creates a
String
object and sets it equal to
the first 10 characters of the
String
description;
String front = description.substring(0, 10);
3.3
Packages
SR 3.10
A Java package is a collection of related classes. The Java standard
class library is a group of packages that support common programming
tasks.
SR 3.11
Each package contains a set of classes that support particular program-
ming activities. The classes in the
java.net
package support network
communication and the classes in the
javax.swing
class support the
development of graphical user interfaces.
SR 3.12
The
Scanner
class and the
Random
class are part of the
java.util
package.
The
String
and
Math
classes are part of the
java.lang
package.
SR 3.13
The
Point
class, according to the online Java API documentation, rep-
resents a location with coordinates (x, y) in two-dimensional space.
SR 3.14
An
import
statement establishes the fact that a program uses a particu-
lar class, specifying what package that class is a part of. This allows the
programmer to use the class name (such as
Random
) without having to
fully qualify the reference (such as
java.util.Random
) every time.
SR 3.15
The
String
class is part of the
java.lang
package, which is automati-
cally imported into any Java program. Therefore, no separate import
declaration is needed.
3.4
The
Random
Class
SR 3.16
A call to the
nextInt
method of a
Random
object returns a random inte-
ger in the range of all possible
int
values, both positive and negative.
Search WWH ::
Custom Search