Java Reference
In-Depth Information
A regular expression is a sequence of characters that describe a pattern of characters. We
discussed how to represent a regular expression in Java using the
compile
method of the
Pattern
class, and how to search for a match to a
Pattern
using the
matcher
method of
the
Matcher
class. The
String.split
method splits a
String
object into an array of
String
objects based on a regular expression. The
Scanner
class is a text scanner that parses primi-
tive data types and strings into tokens using a delimiter, and is also useful for reading key-
board input from the console.
Be sure to test your knowledge of these API contents by answering the Review Questions
at the end of the chapter. Make sure you have a good understanding of the following Exam
Essentials before you attempt the Review Questions.
Exam Essentials
Understand autoboxing and unboxing.
Since the addition of autoboxing and unboxing to
Java, the need for using the wrapper classes explicitly has been minimized greatly. Be sure
to understand when a primitive type is autoboxed or unboxed.
Be familiar with the various string methods.
The
concat
method in
String
creates a new
String
object. Understand how the
append
and
insert
methods of
StringBuilder
and
StringBuffer
behave.
Be familiar with the basic methods of the
File
class.
The
java.io.File
class only repre-
sents a pathname to a fi le or directory and does not contain any methods for accessing or
modifying the contents of a fi le. However, you
can
use the
File
class to create and delete
fi les and directories.
Understand Java object serialization.
Understand what it means for an object to be seri-
alizable and how to serialize and deserialize an object using the
ObjectOutputStream
and
ObjectInputStream
classes.
Know how to format and parse numbers, currency, and dates for a given locale.
You
won't be expected know all the foreign locales, but you should be able to format or parse a
number, currency, or date in the U.S. locale using the
NumberFormat
,
DecimalFormat
, and
DateFormat
classes in
java.text
.
Be able to interpret simple regular expressions.
Know the patterns and metacharacters
you need to for the exam. You won't see a complex and confusing regular expression on the
exam, but you should be able to answer questions that contain simple regular expressions
used in places like
Pattern
,
Scanner
, and
String.split
.
Understand the format specifiers for
format
/
printf
.
Expect to see a question or two
on the exam that uses the format specifi ers found in the
format/printf
methods of the
PrintWriter
and
Formatter
classes. The exam objectives specifi cally list
%b
,
%c
,
%d
,
%f
,
and
%s
.
Search WWH ::
Custom Search