Scanner class
searches, 484–485
tokenizing with, 487–489
scheduling threads, 688–689
scope, variable
for loops and, 337
overview, 190–193
two-minute drill, 255
searches, 472–485
classes, 766–767
collections and arrays, 557–758
dot (.) metacharacter and, 479
greedy quantifiers, 479–481
metacharacter and string collisions, 481–482
metacharacters, 474–476
overview, 472–473
pattern matching, 482–484
quantifiers, 476–479
scanner class and, 484–485
simple, 473–474
self test answers
access control, 77–80
assertions, 399–410
assignments, 266–274
collections, 622–634
dates, numbers, and currency, 508–520
declaration, of class members, 77–80
declaration, of classes, 77–80
development, 789–798
exception handling, 399–410
flow control, 399–410
formatting, 508–520
generic collections, 622–634
I/O (input/output), 508–520
inner classes, 665–672
object orientation, 164–172
operators, 307–314,
serialization, 508–520
strings, 508–520
threads, 744–757
tokenizing, 508–520
self test questions
access control, 75–76
assertions, 389–398
assignments, 259–265
collections, 611–621
dates, numbers, and currency, 498–507
declaration, of class members, 75–76
declaration, of classes, 75–76
development, 781–788
exception handling, 389–398
flow control, 389–398
formatting, 498–507
generic collections, 611–621
I/O (input/output), 498–507
inner classes, 659–664
object orientation, 158–163
operators, 301–306
serialization, 498–507
strings, 498–507
threads, 733–743
tokenizing, 498–507
serialization
inheritance and, 452–456
not using for statics, 456–457
ObjectOutputStream and ObjectInputStream, 444–445
overview, 443–444
saving entire "object graph," 445–449
self test answers, 508–520
self test questions, 498–507
two-minute drill, 495
writeObject and readObject, 449–452
Set interface
in Collections Framework, 537–538
HashSet, 542
LinkedHashSet, 543
methods, 569–570
overview, 542–543
toArray(), 559
TreeSet, 543
working with sets, 561–563
set methods, JavaBeans naming rules, 9
sets, collection. See Set interface
setTime method, Date class, 460–461
shadowing variables, 206–208
short, 324
short-circuit logical operators (&& and | |), 294–296
sleep(), thread methods, 693–696, 699
sort(), 552
sorting collections, 541
Arrays.sort(), 556
Comparable interface for sorting, 551–553
Comparator interface for sorting, 554
overview, 548–551
source file declaration rules, 11–12
split(), String class, 486–487
stack
review of, 174–175
two-minute drill, 255
standards, JavaBeans, 8–9
start()
starting multiple threads, 684–688
starting threads, 681–684
state (instance variables), 2
states, thread, 690–692
static imports, 776–777, 780
static inner classes. See static nested classes
static methods
local classes and, 646
outer class, 641
synchronizing, 709
static nested classes, 654–656
instantiating and using, 655
overview, 654–655
two-minute drill, 658
static variables, 141–147
accessing static methods and variables, 143–147
declaring, 59–60
methods, 141–143
not using serialization with, 456–457
two-minute drill, 73, 157
variable scope and, 191
stream classes
DataOutputStream and DataInputStream, 457
I/O and, 430
ObjectOutputStream and ObjectInputStream, 444–445
strictfp, 46
String class
methods, 420–424
overview, 412
public boolean equalsIgnoreCase(String s), 422
public char charAt(int index), 421
public int length(), 422
public String concat(String s), 421–422
public String replace(char old, char new), 422
public String substring (int begin), 422–423
public String substring (int begin, int end), 422–423
public String tolowerCase(), 423
public String toString(), 424
public String toUpperCase(), 424
public String trim(), 424
split(), 486–487
vs. StringBuffer, 427
string concatenation operator, 287–289, 300
string constant pool, 420
string literals, 180
StringBuffer class
methods, 426–428
overview, 424–425
vs. String, 427
vs. StringBuilder, 425
using, 425–426
StringBuilder class
methods, 426–428
overview, 424–425
vs. StringBuffer class, 425
using, 425–426
strings
creating, 420
immutability of, 412–419
important String class methods, 420–424
memory and, 419–420
metacharacter and string collisions, 481–482
overview, 412
self test answers, 508–520
self test questions, 498–507
String class, 412
StringBuffer and StringBuilder Classes, 424–426
StringBuffer and StringBuilder methods, 426–428
two-minute drill, 494
substring(), String class methods, 422–423
subtraction (-) operator, 286
super(), constructors, 139
superclass, invoking superclass versions of overridden methods, 103–104
switch statements, 316
break in, 326–328
default case for, 329–330
exercise creating switch-case statement, 330
fall-through in, 328
legal expressions of, 323–326
overview, 322–323
two-minute drill, 385
synchronized, class member declaration, 45
synchronizing code, 700
exercise synchronizing block of code, 710–711
locks and, 707–709
overview, 700–705
preventing account overdraw, 705–707
static methods and, 709
thread deadlocks, 717–718
thread locks and, 711–712
thread-safe classes and, 714–716
when to do, 712–714
syntax, inner classes, 649
system properties, 764–765
System.out.println(), 487