C+ +, 96
Calendar class
defined, 458
instance creation, 471
overview, 461–463
case constants
default case for switch statements, 329–330
entry point and, 326–527
exercise creating switch-case statement, 330
legal expressions of, 323–326
casting primitives and primitive ranges, 255
"catch or declare" requirement, 360, 362
catch statement
catching exceptions, 345–347
defining exceptions and, 353–354
exception declaration and, 359
exception matching and, 357–359
handling entire class hierarchy of exceptions, 356
legal expressions of, 349–350
throwing new exceptions or rethrowing exceptions, 364–365
uncaught exceptions and, 350–351
"chained methods," 428
chaining I/O classes, 435–438
char, 324, 330
character literals, 179–180
characters, equality operators, 280
charAt(),421
class members, declaring. See declaration, of class members
classes
abstract, 16–18
accessing, 13
collection, 537–538
dates, numbers, and currency, 458
declaring. See declaration, of classes
default access, 13–14
defined, 2
exception hierarchy, 356–357
exercise creating abstract superclass and concrete subclass, 18–19
extends and implements used with, 120–121
final, 15–16
I/O,429–430
implementing more than one interface, 115–121
inner. See inner classes
instanceof, 284–285
modifiers, 68–69
naming conventions, 7
organization, 3–4
public access, 14–15
searching for, 766–767
string. See strings
thread-safe, 714–716
classpaths, 767–768
close(), 435
code
compiling assertion-aware code, 376–377
Java conventions, 6
reuse, 87–88
synchronization. See synchronizing code
cohesion, 147, 149–150, 157
Collection interface, 537–539, 545
collections. See also generic collections
ArrayList class, 547–548
Arrays.sort(), 556
autoboxing, 548
Comparable interface for sorting, 551–554
converting arrays to lists and lists to arrays, 559
hashCode() and, 530–532
key interfaces and classes, 537–540
legacy approach to, 572–575
List interface, 541–542, 560–561
Map interface, 543–544, 563–566
methods for arrays and collections, 568
methods for lists, sets, maps, and queues, 569–570
mixing generic and non-generic, 576–582
operations related to, 536–537
ordered, 540
overview, 536, 546
Queue interface, 544–545, 566–567
searching, 557–758
self test answers, 622–634
self test questions, 611–621
serialization and, 456
Set interface, 542–543, 561–563
sorting, 541, 548–551
two-minute drill, 607–608
types of, 539
Collections class, 539
command-line arguments
handling, 765–766
not using assertions to validate, 381
command-line switches, for enabling/disabling assertions, 378–379
Comparable interface
vs. Comparator, 555
sorting collections, 551–553
Comparator interface
vs. Comparable interface, 555
ordering PriorityQueue, 566
sorting collections, 554
compareTo(), 551–552
comparison operators, 279
"compilation fails," 338, 578–579
compiler-generated constructors, 133–134
"compiles without error," 578–579
compiling code
assertion-aware code, 376–377
compile time protection and generics, 580–581
with -d, 761–763
with javac, 760–761
compound assignment (+=, -= , *=, and /=) operators, 277–278
concat(), 421–422
concatenation, string concatenation operator, 287–289
concrete subclass, 18–19
conditional operators. See also booleans
overview, 292–293
two-minute drill, 300
constants
case. See case constants
interface, 22–23
naming conventions, 7–8
constructing arrays, 256
constructor arguments, wrapper classes, 228
constructor declarations, 47–48, 63–65
constructors
arguments of, 132
array, 210
chaining, 128–129
compiler-generated, 133–134
determining when default constructors are created, 131–135
first line must be call to super() or to this(), 139
instantiating class objects with, 140–141
overloaded, 135–141
overview, 126–128
rules for, 129–130
thread, 680
two-minute drill, 155–157
wrapper classes, 229
continue statements
iteration and, 340–341
as labeled statement, 342–344
two-minute drill, 386
as unlabeled statement, 341–342
conversion value, format strings, 490
coupling
overview, 147–149
two-minute drill, 157