Java Reference
In-Depth Information
Package
Description
Some Java SE 8 Packages Used in This Topic
java.time
The new Java SE 8
Date/Time API Package
contains classes and inter-
faces for working with dates and times. These features are designed to
replace the older date and time capabilities of package
java.util
. (See
Chapter 23, Concurrency.)
java.util.function
and
java.util.stream
These packages contain classes and interfaces for working with Java
SE 8's functional programming capabilities. (See Chapter 17, Java SE 8
Lambdas and Streams.)
Fig. 6.5
|
Java API packages (a subset). (Part 2 of 2.)
The set of packages available in Java is quite large. In addition to those summarized
in Fig. 6.5, Java includes packages for complex graphics, advanced graphical user inter-
faces, printing, advanced networking, security, database processing, multimedia, accessi-
bility (for people with disabilities), concurrent programming, cryptography, XML
processing and many other capabilities. For an overview of the packages in Java, visit
You can locate additional information about a predefined Java class's methods in the
Java API documentation at
When you visit this site, click the
Index
link to see an alphabetical listing of all the classes
and methods in the Java API. Locate the class name and click its link to see the online de-
scription of the class. Click the
METHOD
link to see a table of the class's methods. Each
static
method will be listed with the word “
static
” preceding its return type.
We now take a brief diversion into a popular type of programming application—simula-
tion and game playing. In this and the next section, we develop a game-playing program
with multiple methods. The program uses most of the control statements presented thus
far in the topic and introduces several new programming concepts.
The
element of chance
can be introduced in a program via an object of class
Secure-
Random
(package
java.security
). Such objects can produce random
boolean
,
byte
,
float
,
double
,
int
,
long
and Gaussian values. In the next several examples, we use objects
of class
SecureRandom
to produce random values.
Moving to Secure Random Numbers
Recent editions of this topic used Java's
Random
class to obtain “random” values. This class
produced
deterministic
values that could be
predicted
by malicious programmers.
Secure-
Random
objects produce
nondeterministic random numbers
that
cannot
be predicted.
Deterministic random numbers have been the source of many software security
breaches. Most programming languages now have library features similar to Java's
Secure-