Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
69 Cards in this Set
- Front
- Back
String objects are ___, and String reference variables are not
|
immutable
|
|
if you create a new String without assigning it
|
it will be lost to your program
|
|
if you redirect a String reference to a new String
|
the old String can be lost
|
|
String methods use zero-based indexes, except for the
|
second argument of substring()
|
|
the String class is ___ - its methods can't be overridden
|
final
|
|
when the JVM finds a String literal, it is added to the
|
String literal pool
|
|
Strings have a method: length(); arrays have
|
an attribute named length
|
|
the StringBuffer's API is the same as the new StringBuilder's API, except that
|
StringBuilder's methods are not synchronized for thread safety
|
|
StringBuilder methods should ___ ___ then StringBuffer methods
|
run faster
|
|
All of the following apply to both StringBuffer and StringBuilder
|
they are mutable - they can change without creating a new object
StringBuffer methods act on the invoking object, and objects can change without an explicit assignment in the statement StringBuffer equals() is not overridden; it doesn't compare values |
|
remember that chained methods are evaluated from ___ to ___
|
left to right
|
|
String methods to remember:
|
charAt(), concat(), equalsIgnoreCase(), length(), replace(), substring(), toLowerCase(), toString(), toUpperCase(), and trim()
|
|
StringBuffer methods to remember:
|
append(), delete(), insert(), reverse(), and toString()
|
|
the classes you need to understand in java.io are
|
File, FileReader, BufferedReader, FileWriter, BufferedWriter, and PrintWriter
|
|
a new File object doesn't mean
|
there's a new file on your hard drive
|
|
File objects can represent either
|
a file or a directory
|
|
the ___ class lets you manage (add, rename, and delete) files and directories
|
File
|
|
the methods ___ and ___ add entries to your file system
|
createNewFile() and mkDir()
|
|
___ and ___ are low-level I/O classes. you can use them to write and read files, but they should usually be wrapped
|
FileWriter and FileReader
|
|
classes in java.io are designed to be ___ or ___. this is a common use of the decorator design pattern
|
"chained" or "wrapped"
|
|
it's very common to "wrap" a BufferedReader around a ___ to get access to higher-level, more convenient methods
|
FileReader
|
|
it's very common to "wrap" a BufferedWriter around a ___ to get access to higher-level, more convenient methods
|
FileWriter
|
|
PrintWriters can be used to wrap other Writers, but as of Java 5 they can be built directly from
|
Files or Strings
|
|
Java 5 PrintWriters have new ___ methods
|
append(), format(), and printf()
|
|
the classes you need to understand are all in the java.io package; they include:
|
ObjectOutputStream and ObjectInputStream primarily, and FileOutputStream and FileInputStream because you will use them to create the low-level streams that the ObjectXxxStream classes will use
|
|
a class must implement the ___ interface before its objects can be serialized
|
Serializable
|
|
the ___ method serializes objects, and the ___ method deserializes objects
|
ObjectOutputStream.writeObject(), ObjectInputStream.readObject()
|
|
if you mark an instance variable ___, it will not be serialized even though the rest of the object's state will be
|
transient
|
|
you can supplement a class's automatic serialization process by implementing the ___ and ___ methods. if you do this, embedding calls to defaultWriteObject() and defaultReadObject(), respectively, will handle the part of serialization that happens normally
|
writeObject() and readObject()
|
|
if a superclass implements Serializable, then its subclasses
|
do automatically
|
|
if a superclass doesn't implement Serializable, then when a subclass object is deserialized
|
the superclass constructor will run
|
|
the classes you need to understand are
|
java.util.Date, java.util.Calendar, java.text.DateFormat, java.text.NumberFormat, and java.util.Locale
|
|
most of the Date class's methods have been
|
deprecated
|
|
a Date is stored as a
|
long, the number of milliseconds since January 1, 1970
|
|
Date objects are go-betweens for the
|
Calendar and Locale classes
|
|
the ___ provides a powerful set of methods to manipulate dates, performing tasks such as getting days of the week, or adding some number of months or years (or other increments) to a date
|
Calendar
|
|
create Calendar instances using
|
static factory methods (getInstance())
|
|
the Calendar methods you should understand are
|
add(), which allows you to add or substract various pieces (minutes, days, years, and so on) of dates, and roll(), which works like add() but doesn't increment a date's bigger pieces. (for example: adding 10 months to an October date changes the month to August, but doesn't increment the Calendar's year value)
|
|
DateFormat instances are created using static factory methods ___
|
getInstance() and getDateInstance()
|
|
There are several format ___ available in the DateFormat class
|
"styles"
|
|
___ ___ can be applied against various Locales to create a wide
array of outputs for any given date |
DateFormat styles
|
|
The ___ method is used to create Strings containing
properly formatted dates |
DateFormat.format()
|
|
The ___ class is used in conjunction with DateFormat and NumberFormat
|
Locale
|
|
Both DateFormat and NumberFormat objects can be constructed with a
specific, immutable ___ |
Locale
|
|
For the exam
|
you should understand creating Locales using language, or a
combination of language and country |
|
regex is short for regular expressions, which are the
|
patterns used to search for
data within large data sources |
|
regex is a ___ that exists in Java and other languages (such as Perl)
|
sub-language
|
|
regex lets you create search patterns using literal characters or
___. They allow you to search for slightly more abstract data like "digits" or "whitespace" |
metacharacters
|
|
Study the
|
\d, \s, \w, and . metacharacters
|
|
regex provides for ___ which allow you to specify concepts like: "look
for one or more digits in a row." |
quantifiers
|
|
Study the
|
?, *, and + greedy quantifiers
|
|
Remember that metacharacters and Strings don't mix well unless you
remember to |
"escape" them properly. For instance String s = "\\d";
|
|
The ___ and ___ classes have Java's most powerful regex capabilities
|
Pattern and Matcher
|
|
You should understand the
|
Pattern compile() method and the Matcher
matcher(), pattern(), find(), start(), and group() methods |
|
You WON'T need to understand
|
Matcher's replacement-oriented methods
|
|
You can use java.util.Scanner to do simple regex searches, but it is primarily
intended for ___ |
tokenizing
|
|
___ is the process of splitting delimited data into small pieces
|
Tokenizing
|
|
In tokenizing, the data you want is called ___, and the strings that separate
the tokens are called ___ |
tokens, delimiters
|
|
Tokenizing can be done with the
|
Scanner class, or with String.split()
|
|
___ are single characters like commas, or complex regex expressions
|
Delimiters
|
|
The ___ class allows you to tokenize data from within a loop, which
allows you to stop whenever you want to |
Scanner
|
|
The Scanner class allows you to ___ Strings or streams or files
|
tokenize
|
|
The ___ method tokenizes the entire source data all at once, so
large amounts of data can be quite slow to process |
String.split()
|
|
New to Java 5 are two methods used to format data for output. These
methods are ___ |
format() and printf(). These methods are found in the
PrintStream class, an instance of which is the out in System.out |
|
The format() and printf() methods have ___
|
identical functionality
|
|
Formatting data with printf() (or format()) is accomplished using
|
formatting strings that are associated with primitive or string arguments
|
|
The format() method allows you to mix
|
literals in with your format strings
|
|
The format string values you should know are
|
Flags: -, +, 0, "," , and (
Conversions: b, c, d, f, and s |
|
If your conversion character doesn't match your argument type
|
an exception
will be thrown |