Index

Numbers

- (minus sign)

arithmetic operator, 56, 64

printf flag, 84

-- operator, 61, 64

_ (underscore)

delimiter, in number literals, 48

in instance field names (C++), 176

, (comma)

operator (C++), 65

printf flag, 8384

; (semicolon)

for statements, 45, 53

in class path (Windows), 191

: (colon)

in assertions, 385

in class path (UNIX), 191

inheritance token (C++), 204

:: operator (C++), 153, 161, 207, 320

! operator, 62, 64

!= operator, 62, 64, 101

?: operator, 62, 64

/ (slash)

arithmetic operator, 56, 64

in file names, 785

// comments, 46

/* . . . */ comments, 46

/** . . . */ comments, 46, 194

. (period)

in class path, 191192

in directory names (UNIX), 788

... (ellipsis), in varargs, 257

^ operator, 6364, 316

~ operator, 6364

', " (single, double quote), escape sequences for, 50

". . ." (double quotes), for strings, 45

( (left parenthesis), printf flag, 8384

() (empty parentheses), in method calls, 46

(. . .) (parentheses)

for casts, 60, 64, 219

for operator hierarchy, 6465

[] (empty square brackets), in generics, 421

[. . .] (square brackets), for arrays, 111, 115

{. . .} (curly braces)

for blocks, 4445, 89

for enumerated type, 65

in lambda expressions, 316

{{. . .}} (double curly braces), in inner classes, 344

@ (at), in javadoc comments, 194, 196

$ (dollar sign)

delimiter, for inner classes, 336

in variable names, 53

printf flag, 84

* (asterisk)

arithmetic operator, 56, 64

echo character, 652

in class path, 191

in imports, 183

\ (backslash)

escape sequence for, 50

in file names, 87, 785

& (ampersand)

bitwise operator, 6364

in bounding types, 423

in reference parameters (C++), 169

&& operator, 62, 64

# (number sign)

in javadoc hyperlinks, 197

in property files, 599

printf flag, 84

% (percent sign)

arithmetic operator, 56, 64

formatting output for, 83

printf flag, 84

+ (plus sign)

arithmetic operator, 56, 60, 64

for objects and strings, 6667, 239

printf flag, 84

++ operator, 61, 64

< (left angle bracket)

in shell syntax, 88

printf flag, 8485

relational operator, 62, 64

<? (in wildcard types), 443

<<, >>, >>> operators, 6364

<= operator, 62, 64

<. . .> (angle brackets), for type parameters, 245, 419

> (right angle bracket)

in shell syntax, 88, 411

relational operator, 62, 64

-> (in lambda expressions), 315317

>& (in shell syntax), 411

>= operator, 62, 64

= operator, 54, 61

== operator, 62, 64

for class objects, 262

for enumerated types, 258

for floating-point numbers, 101

for identity hash maps, 507

for strings, 69

for wrappers, 254

| operator, 6364

|| operator, 62, 64

0, 0b, 0x prefixes (in integers), 48

0, printf flag, 84

2> (in shell syntax), 411

2D shapes, 560569

A

Absolute positioning (Swing), 723

Abstract classes, 221227

extending, 223

interfaces and, 297

object variables of, 223

abstract keyword, 221227

Abstract methods, 222

in functional interfaces, 318

AbstractAction class, 609, 612, 680, 683

AbstractButton class, 627, 681684

is/setSelected methods, 684

setAction method, 681

setActionCommand method, 663

setDisplayedMnemonicIndex method, 686, 688

setHorizontalTextPosition method, 682683

setMnemonic method, 688

abstractClasses/Employee.java, 226

abstractClasses/Person.java, 226

abstractClasses/PersonTest.java, 225

abstractClasses/Student.java, 227

AbstractCollection class, 467, 479

AbstractQueue class, 463

Accelerators (in menus), 687688

accept method (FileFilter), 755, 764

acceptEither method (CompletableFuture), 934

Access modifiers

checking, 265

final, 55, 157, 217218, 295, 339342, 886

private, 150, 189190, 333

protected, 227228, 283, 311

public, 4243, 56, 147150, 189190, 289290

public static final, 296

static, 4445, 158164

static final, 55

void, 4445

Access order, 505

AccessibleObject class

isAccessible method, 275

setAccessible method, 272, 275

Accessor methods, 141145, 153154, 444

Accessory components, 757

accumulate method (LongAccumulator), 888

accumulateAndGet method (AtomicType), 887

Action interface, 607615, 680

actionPerformed method, 608

add/removePropertyChangeListener methods, 608609

get/putValue methods, 608, 615

is/setEnabled methods, 608, 615

predefined action table names, 609

Action listeners, 607615

action/ActionFrame.java, 613

ActionEvent class, 588, 626627

getActionCommand method, 598, 627

getModifiers method, 627

ActionListener interface, 626

actionPerformed method, 302303, 314, 331332, 337, 342, 589593, 597, 601, 607, 609, 627, 897

overriding, 680

implementing, 318, 589, 597

ActionMap class, 612

Actions, 607615

associating with keystrokes, 610

asynchronous, 931

names of, 612

predefined, 609

ActiveX, 5, 15

Adapter classes, 603607

add method

of ArrayList, 245251

of BigDecimal, BigInteger, 110111

of BlockingQueue, 898899

of ButtonGroup, 663

of Collection, 463, 467469

of Container, 591, 595, 641

of GregorianCalendar, 142

of HashSet, 487

of JFrame, 555, 559

of JMenu, 679, 681

of JToolBar, 695699

of List, 470, 482

of ListIterator, 470, 476478, 483

of LongAdder, 888

of Queue, 494

of Set, 471

addAll method

of ArrayList, 417

of Collection, 467468

of Collections, 523

of List, 482

addChoosableFileFilter method (JFileChooser), 763

addComponent, addGroup methods (GroupLayout), 723

addFirst/Last methods

of Deque, 494

of LinkedList, 484

addHandler method (Logger), 406

addItem method (JComboBox), 669671

Addition operator, 56, 64

for different numeric types, 60

for objects and strings, 6667, 239

addLayoutComponent method (LayoutManager), 728

addPropertyChangeListener method (Action), 608609

addSeparator method

of JMenu, 679, 681

of JToolBar, 695699

addShutdownHook method (Runtime), 182

addSuppressed method (Throwable), 377, 380

AdjustmentEvent class, 626

methods of, 627

AdjustmentListener interface, 626

adjustmentValueChanged method, 627

Adobe Flash, 9

Aggregation, 133135

Algorithms, 130

for binary search, 521522

for shuffling, 520

for sorting, 518521

QuickSort, 117, 519

simple, in the standard library, 522524

writing, 526528

Algorithms + Data Structures = Programs

(Wirth), 130

Algorithms in C++ (Sedgewick), 519

Alice in Wonderland (Carroll), 487, 490

allOf method (EnumSet), 508, 934

Alt+F4, in Windows, 688

and, andNot methods (BitSet), 533

Andreessen, Mark, 10

Annotations, 430

Anonymous arrays, 114

Anonymous inner classes, 329, 342345

anonymousInnerClass/AnonymousInnerClassTest.java, 344

Antisymmetry rule, 295

anyOf method (CompletableFuture), 934

append method

of JTextArea, 656, 951

of StringBuilder, 7778

appendCodePoint method (StringBuilder), 78

Applet class, 803

destroy method, 808

getAppletContext method, 818820

getAppletInfo method, 816

getCodeBase, getDocumentBase methods, 816817

getImage, getAudioClip methods, 817

getParameter method, 810811, 816

getParameterInfo method, 816

init method, 807, 811

play method, 817

resize method, 808

showStatus method, 819820

start, stop methods, 808

applet element (HTML), 34, 805, 808810

align attribute, 808

alt attribute, 809

archive attribute, 809

code attribute, 809

codebase attribute, 809

height, width attributes, 807808

hspace, vspace attributes, 808

name attribute, 810

object attribute (obsolete), 809

applet/NotHelloWorld.java, 805

AppletContext interface, 818

getApplet, getApplets methods, 818, 820

showDocument method, 819820

Applets, 89, 14, 802824

accessing from JavaScript, 810

aligning, 808

changing warning string in, 190

communicating to each other, 810, 818

context of, 818

debugging, 807

digitally signed, 822824

executing, 805

image and audio files in, 816817

multiple copies of, 813

no title bars for, 807

passing information to, 816

printing in, 832

resizing, 808810

running in a browser, 8, 3339, 802803, 818820

serialized objects of, 809

testing, 805806

trusted local, 35, 806

appletviewer program, 33, 805806

Application Programming Interfaces (APIs), online documentation, 71, 7477

Applications

cache of, 827

closing by user, 545

codebase of, 831

compiling/running from the command line, 3033

debugging, 2526, 358366

deploying, 779838

extensible, 217

launching, 43

localization of, 136, 393394, 785

monitoring and managing in JVM, 412

platform-independent, 724

preferences of, 788800

terminating, 45

testing, 384388

applyToEither method (CompletableFuture), 934

Arguments. See Parameters

Arithmetic operators, 5665

accuracy of, 56

autoboxing with, 253

combining with assignment, 61

precedence of, 64

Array class, 276279

get, getXxx, set, setXxx methods, 279

getLength method, 277, 279

newInstance method, 276, 279

Array lists, 112, 484

anonymous, 344

capacity of, 246

elements of:

accessing, 247251

adding, 245249

removing, 249

traversing, 249

generic, 244252

raw vs. typed, 251252

Array variables, 111

ArrayBlockingQueue class, 899, 903

ArrayDeque class, 462, 494495

as a concrete collection type, 472

ArrayIndexOutOfBoundsException, 112, 361363, 938

ArrayList class, 113, 244252, 416418, 474

add method, 245251

addAll method, 417

as a concrete collection type, 472

ensureCapacity method, 246247

get, set methods, 247, 251

remove method, 249, 251

removeIf method, 319

size method, 246247

synchronized, 914

toArray method, 435

trimToSize method, 246247

arrayList/ArrayListTest.java, 250

Arrays, 111127

anonymous, 114

circular, 462463

cloning, 311

converting to collections, 525526

copying, 114115

on write, 912

creating, 111

elements of:

computing in parallel, 913

numbering, 112

remembering types of, 214

removing from the middle, 474

traversing, 112113, 122

equality testing for, 234

generic methods for, 276279

hash codes of, 238

in command-line parameters, 116

initializing, 112, 114

multidimensional, 120125, 240

not of generic types, 321, 431432, 441

of integers, 240

of subclass/superclass references, 214

of wildcard types, 432

out-of-bounds access in, 360

parallel operations on, 912

printing, 122, 240

ragged, 124127

size of, 112, 246, 277

equal to 0, 114, 526

equal to 1, 341

increasing, 115

setting at runtime, 244

sorting, 117120, 292, 912

type erasure and, 434436

Arrays class

asList method, 509, 516, 526

binarySearch method, 120, 352

copyOf method, 115, 119, 276

copyOfRange method, 119

deepToString method, 122, 240

equals method, 120, 234

fill method, 120

hashCode method, 238

sort method, 117119, 290, 292, 294, 314, 318

toString method, 114, 119

arrays/CopyOfTest.java, 278

ArrayStoreException, 431, 433, 441

Ascender, ascent (in typesetting), 576

ASCII standard, 51, 575

asList method (Arrays), 509, 516, 526

assert keyword, 384388

Assertions, 384388

checking parameters with, 386387

defined, 384

documenting assumptions with, 387388

enabling/disabling, 385386

Assignment operator, 54, 61

Asynchronous methods, 915

atan, atan2 methods (Math), 58

Atomic operations, 886889

client-side locking for, 883

in concurrent hash maps, 907909

performance of, 888

AtomicType classes, 887

Audio files, accessing from applets, 816817

@author comment (javadoc), 196, 199

Autoboxing, 252256

AutoCloseable interface, 376

close method, 376377

await method (Condition), 856, 873877, 893895

awaitUninterruptibly method (Condition), 893895

AWT (Abstract Window Toolkit), 538

events in:

debugging, 774778

hierarchy of, 624628

tracing, 771

preferred field sizes in, 649

AWTEvent class, 624

B

\b (backspace escape sequence), 50

Background

default color for, 570571

erasing, 842

painting, 558

Backspace, escape sequence for, 50

BadCastException, 451

Barriers, 936937

Base classes. See Superclasses

Baseline (in typesetting), 576, 718

Basic multilingual planes, 51

BasicButtonUI class, 637

BasicService interface, 831

getCodeBase method, 831, 836

isWebBrowserSupported method, 836

showDocument method, 836

Batch files, 193

Beans, 780

beep method (Toolkit), 305

BiConsumer interface, 326

BiFunction interface, 319, 326

BIG-5 standard, 51

BigDecimal, BigInteger classes, 108111

add, compareTo, subtract, multiply, divide, mod methods, 110111

valueOf method, 108, 110111

BigIntegerTest/BigIntegerTest.java, 109

Binary search, 521522

BinaryOperator interface, 326

binarySearch method

of Arrays, 120, 352

of Collections, 521522

BiPredicate interface, 326

Bit masks, 63, 616

Bit sets, 532536

and the sieve of Eratosthenes benchmark, 533536

Bitecode files, 43

BitSet interface, 460, 532536

methods of, 533

Bitwise operators, 6364

Blank lines, printing, 46

Blocking queues, 898905

BlockingDeque interface

offerFirst/Last, pollFirst/Last methods, 905

putFirst/Last, takeFirst/Last methods, 904

BlockingQueue interface

add, element, peek, remove methods, 898899

offer, poll, put, take methods, 898899, 904

blockingQueue/BlockingQueueTest.java, 900

Blocks, 4445, 8990

nested, 89

Boolean class

converting from boolean, 252

hashCode method, 237

boolean operators, 62, 64

boolean type, 52

default initialization of, 172

formatting output for, 83

no casting to numeric types for, 61

BooleanHolder class, 255

Border layout manager, 641644

border/BorderFrame.java, 665

BorderFactory class, 664668

createTypeBorder methods, 664667

BorderLayout class, 641644

constants of, 642

Borders, 664668

compound, 664

rounded corners of, 665

styles of, 664

with a title, 664

bounce/Ball.java, 844

bounce/BallComponent.java, 845

bounce/Bounce.java, 842

bounceThread/BounceThread.java, 849

Bounded collections, 463

Bounding rectangle, 563565

Bounds checking, 115

Box layout, 700

break statement, 104108

labeled/unlabeled, 106

missing, 412

Bridge methods, 428429, 440

brighter method (Color), 571

BrokenBarrierException, 937

Browsers

default, 831

display area of, 819820

installing Java Plug-in in, 803

Java-enabled, 809

MIME types in, 825

running applets in, 8, 3339, 802803, 818820

status bar of, 819820

Buckets (of hash tables), 485

Bulk operations, 524525

button/ButtonFrame.java, 594

ButtonGroup class, 660

add method, 663

getSelection method, 661, 663

ButtonModel interface, 636638

getActionCommand method, 661, 663

getSelectedObjects method, 661

properties of, 637

Buttons

appearance of, 632

associating actions with, 610

clicking, 592

creating, 591

event handling for, 591595

listening to, 592

model-view-controller analysis of, 636638

rearranging automatically, 639

ButtonUIListener class, 637

Byte class

converting from byte, 252

hashCode method, 237

byte type, 47

ByteArrayOutputStream class, 830

C

C programming language

assert macro in, 385

event-driven programming in, 588

function pointers in, 279

integer types in, 6

C# programming language, 8

delegates in, 280

polymorphism in, 218

useful features of, 11

C++ programming language

, (comma) operator in, 65

:: operator in, 153, 207

>> operator in, 64

access privileges in, 156

algorithms in, 518

arrays in, 115, 126

bitset template in, 532

boolean values in, 52

classes in, 45

nested, 330

code units and code points in, 70

control flow in, 89

copy constructors in, 139

dynamic binding in, 209

dynamic casts in, 221

exceptions in, 361, 364365, 369

fields in:

instance, 175176

static, 161

for loop in, 100

function pointers in, 279

#include in, 184

inheritance in, 204, 213, 297

integer types in, 6, 47

methods in:

accessor, 142

default, 300

destructor, 181

static, 161

namespace, using directives in, 184

new operator in, 151

NULL, object pointers in, 139

operator overloading in, 109

passing parameters in, 167, 169

performance of, compared to Java, 534

polymorphism in, 218

protected modifier in, 228

pure virtual functions (= 0) in, 224

references in, 139

Standard Template Library in, 460, 465

static member functions in, 45

strings in, 6869

superclasses in, 208

syntax of, 3

templates in, 11, 420, 423, 426

this pointer in, 176

type parameters in, 422

using iterators as parameters in, 530

variables in, 55

redefining in nested blocks, 90

vector template in, 247

virtual constructors in, 263

void* pointer in, 229

Cache, 827

calculator/CalculatorPanel.java, 645

Calendar class, 140

get/setTime methods, 218

Calendars

displaying, 142144

vs. time measurement, 140

CalendarTest/CalendarTest.java, 144

Call by reference, 164

Call by value, 164171

Callable interface, 927

call method, 915, 919

wrapper for, 916

Callables, 915920

Callbacks, 302305

Camel case (CamelCase), 43

cancel method (Future), 915, 920921, 945

CancellationException, 945

Canned functionality, 934

canRead/Write methods (FileContents), 837

Carriage return, escape sequence for, 50

case statement, 104

cast method (Class), 451

Casts, 6061, 219221

bad, 360

checking before attempting, 220

catch statement, 367381

ceiling method (NavigableSet), 493

ChangeListener interface, 672

stateChanged method, 672673

char type, 5051

Character class

converting from char, 252

hashCode method, 237

isJavaIdentifierXxx methods, 53

Characters, formatting output for, 83

charAt method (String), 70, 72

chart/Chart.java, 813

checkBox/CheckBoxFrame.java, 658

Checkboxes, 657659

in menus, 683684

Checked exceptions, 261264

applicability of, 383

declaring, 361364

suppressing with generics, 437439

Checked views, 513

checkedCollection methods (Collections), 515

Child classes. See Subclasses

Choice components, 657678

borders, 664668

checkboxes, 657659

combo boxes, 668671

radio buttons, 660663

sliders, 672678

ChronoLocalDate interface, 446

Church, Alonzo, 315

circleLayout/CircleLayout.java, 725

circleLayout/CircleLayoutFrame.java, 728

Circular arrays, 462463

Clark, Jim, 10

Clarke, Arthur C., 717

Class class, 261263

cast method, 451

forName method, 261, 265

generic, 434, 450453

getClass method, 261

getComponentType method, 277

getConstructor, getDeclaredConstructor methods, 451

getConstructors, getDeclaredConstructors methods, 266, 270

getDeclaredMethods method, 266, 270, 280

getEnumConstants method, 451

getField, getDeclaredField methods, 275

getFields, getDeclaredFields methods, 266, 270, 272, 275

getGenericXxx methods, 457

getImage, getAudioClip methods, 784

getMethod method, 280

getMethods method, 266, 270

getName method, 244, 261262

getResource, getResourceAsStream methods, 784, 787

getSuperclass method, 244, 451

getTypeParameters method, 457

newInstance method, 263, 265, 451

Class constants, 55

Class diagrams, 134135

.class file extension, 43

Class files, 185, 190

locating, 192

names of, 43, 147

class keyword, 42

Class loaders, 351, 385

Class path, 190193

checking directories on, 412

setting, 193

Class wins rule, 301

Class<T> parameters, 452

ClassCastException, 220, 276, 295, 435, 441, 513

Classes, 131132, 204228

abstract, 221227, 297

access privileges for, 156

adapter, 603607

adding to packages, 185188

analyzing:

capabilities of, 265271

objects of, at runtime, 271276

companion, 298299

constructors for, 149

defining, 145157

at runtime, 350

deprecated, 197

designing, 133, 200202

documentation comments for, 194198

encapsulation of, 131132, 153156

extending, 132

final, 217218

generic, 245, 418420, 441, 669

helper, 706712

immutable, 157

implementing multiple interfaces, 296297

importing, 183184

inner, 329349

anonymous, 606

instances of, 131, 136

loading, 262, 411

multiple source files for, 149

names of, 25, 43, 182, 201

full package, 183

number of basic types in, 200

package scope of, 189

parameters in, 152153

predefined, 135145

private methods in, 156157

protected, 227228

public, 194

accessing, 183

relationships between, 133135

serializable, 412

sharing, among programs, 191

unit testing, 162

wrapper, 252256

ClassLoader class, 388

CLASSPATH environment variable, 26, 193

clear method

of BitSet, 533

of Collection, 467, 469

clearAssertionStatus method (ClassLoader), 388

Client-side locking, 882883

clone method

of array types, 311

of Object, 156, 306313, 318

clone/CloneTest.java, 312

clone/Employee.java, 312

Cloneable interface, 306313

CloneNotSupportedException, 310

close method

of AutoCloseable, 376377

of Closeable, 376

of Handler, 406

Closeable interface, 376

Closures, 323

Code errors, 359

Code planes, 52

Code points, code units, 52, 70

Codebase (in JNLP files), 831

codePointAt, codePoints methods (String), 72

codePointCount method (String), 70, 73

Collection interface, 463, 469, 479

add method, 463, 467469

addAll method, 467468

clear method, 467, 469

contains, containsAll methods, 467468, 479

equals method, 467

generic, 466469

isEmpty method, 299, 467468

iterator method, 463, 468

remove, removeAll methods, 467468

removeIf method, 468, 524

retain method, 467

retainAll method, 469

size method, 467468

toArray method, 249, 467, 469

Collections, 459536

algorithms for, 517528

bounded, 463

bulk operations in, 524525

concrete, 472496

concurrent modifications of, 479

converting to arrays, 525526

debugging, 479

elements of:

inserting, 469

maximum, 517

removing, 465

traversing, 464

interfaces for, 460471

legacy, 528536

lightweight wrappers for, 509510

ordered, 470, 476

performance of, 471, 486

searching in, 521522

sorted, 489

thread-safe, 512513, 905915

type parameters for, 418

using for method parameters, 527

Collections class, 520

addAll method, 523

binarySearch method, 521522

checkedCollection, emptyCollection methods, 515

copy method, 523

disjoint method, 524

fill method, 523

frequency method, 524

indexOfSubList, lastIndexOfSubList methods, 524

min, max methods, 523

nCopies method, 510, 515

replaceAll method, 523

reverse method, 524

rotate method, 524

shuffle method, 520521

singleton, singletonCollection methods, 510, 515

sort method, 518521

swap method, 524

synchronizedCollection methods, 512513, 515, 915

unmodifiableCollection methods, 511512, 514

Collections framework. See Java collections

framework (JCF)

Color choosers, 764770

Color class, 569573

brighter, darker methods, 571

predefined constants, 570

colorChooser/ColorChooserPanel.java, 767

Colors

background, 558, 570571

changing, 609

custom, 570

foreground, 570

predefined, 570572

system, 571

Columns (of a text field), 649

com.sun.java package, 599

Combo boxes, 668671

adding items to, 669

current selection in, 669

comboBox/ComboBoxFrame.java, 670

Command line

compiling/launching Java from, 24

parameters in, 116

Comments, 4647

blocks of, 46

for automatic documentation, 46, 194199

in property files, 599

not nesting, 47

to the end of line, 46

Companion classes, 298299

Comparable interface, 288, 352, 422423, 446, 519

compareTo method, 289293

comparator method (SortedMap), 493, 500

Comparator interface, 305306, 314, 328329, 519

chaining comparators in, 328

comparing method, 328329

lambdas and, 318

naturalOrder method, 329

nullFirst/Last methods, 329

reversed, reverseOrder methods, 329, 519, 521

thenComparing method, 328329

compare method (integer types), 294, 318

compareAndSet method (AtomicType), 887

compareTo method

in subclasses, 295

of BigDecimal, BigInteger, 110111

of Comparable, 289293, 422, 446

of Enum, 260

of String, 72

Compilation errors, 29

Compiler

autoboxing in, 254

bridge methods in, 428

command-line options of, 412

creating bytecode files in, 43

deducting method types in, 421

enforcing throws specifiers in, 368

error messages in, 29, 363

just-in-time, 67, 14, 153, 218, 413, 534

launching, 25

optimizing method calls in, 7, 218

overloading resolution in, 215

shared strings in, 67, 69

translating inner classes in, 336

translating typed array lists in, 252

type parameters in, 417

warnings in, 105, 252

whitespace in, 44

Completable futures, 931934

combining, 933

composing, 932

exception handling in, 933

CompletableFuture class

acceptEither, applyToEither methods, 934

allOf, anyOf methods, 934

handle method, 933

runAfterXxx methods, 934

thenAccept, thenApply, thenApplyAsync, thenRun methods, 933

thenAcceptBoth, thenCombine methods, 934

thenCompose method, 932933

whenComplete method, 933

CompletionStage interface, 934

Component class, 627

getBackground/Foreground methods, 573

getFont method, 651

getPreferredSize method, 557, 559

getSize method, 552

inheritance hierarchies of, 640

isVisible method, 552

repaint method, 556, 559

setBackground/Foreground methods, 570, 573

setBounds method, 546, 548, 552, 724

setCursor method, 624

setLocation method, 546, 548, 552

setSize method, 552

setVisible method, 546, 552, 951

validate method, 651, 951

Components, 639

displaying information in, 553

labeling, 651652

realized, 951

Composite design pattern, 631

CompoundInterest/CompoundInterest.java, 122

Computations

performance of, 56, 59

truncated, 56

compute, computeIfPresent/Absent methods (Map), 501

Concrete collections, 472496

Concrete methods, 222

Concurrent hash maps

atomic updates in, 907909

buckets as trees in, 906

bulk operations on, 909911

efficiency of, 906

size of, 906

Concurrent modification detection, 479

Concurrent programming, 7, 839952

synchronization in, 862897

Concurrent sets, 912

ConcurrentHashMap class, 905907

atomic updates in, 907909

compute, computeIfXxx methods, 908909

forEach method, 910911

get method, 908

keySet, newKeySet methods, 912

mappingCount method, 906

merge method, 909

organizing buckets as trees in, 906

put, putIfAbsent methods, 908

reduce, reduceXxx methods, 910911

replace method, 908

search, searchXxx methods, 910911

vs. synchronization wrappers, 914

ConcurrentLinkedQueue class, 905, 907

ConcurrentModificationException, 478479, 906, 914

ConcurrentSkipListMap class, 905907

ConcurrentSkipListSet class, 905, 907

Condition interface, 878

await method, 856, 893895

awaitUninterruptibly method, 893895

signal, signalAll methods, 890

vs. synchronization methods, 880

Condition objects, 872877

Condition variables, 872

Conditional statements, 9094

config method (Logger), 390, 404

Configuration files, 794800

Confirmation dialogs, 733

Console

debugging applets in, 807

printing messages to, 4246

Console class

reading passwords with, 80

readLine/Password methods, 81

console method (System), 81

ConsoleHandler class, 394399, 407

ConsoleWindow class, 770

const keyword, 56

Constants, 5556

documentation comments for, 196

names of, 55

public, 56, 159

static, 159

Constructor class, 265

getDeclaringClass method, 270

getModifiers method, 265, 270

getName method, 265, 270

getXxxTypes methods, 270

newInstance method, 265, 452

Constructor references, 321322

Constructors, 149151, 171182

calling another constructor in, 176

defined, 136

documentation comments for, 194

field initialization in:

default, 172173

explicit, 174

final, 265

initialization blocks in, 177181

names of, 136, 150

no-argument, 173, 208, 801

overloading, 172

parameter names in, 175

private, 265

protected, 194

public, 194, 265

with super keyword, 207

ConstructorTest/ConstructorTest.java, 179

Consumer interface, 326

Consumer threads, 898

Container class, 639

add method, 591, 595, 641

setLayout method, 641

Containers, 639

contains method

of Collection, 467468, 479

of HashSet, 487

containsAll method (Collection), 467468, 479

containsKey/Value methods (Map), 499

Content pane, 554

continue statement, 108

Control flow, 89108

block scope, 8990

breaking, 106108

conditional statements, 9094

loops, 9499

determinate, 99103

“for each,” 113114

multiple selections, 103105

Controllers, 633

Conversion characters, 8283

Cooperative scheduling, 856

Coordinated Universal Time (UTC), 139

copy method (Collections), 523

copyArea method (Graphics), 583, 586

copyOf method (Arrays), 115, 119, 276

copyOfRange method (Arrays), 119

CopyOnWriteArrayList class, 912, 914

CopyOnWriteArraySet class, 912

Core Java program examples, 23

Cornell, Gary, 1

Corruption of data, 862868

cos method (Math), 58

Count of Monte Cristo, The (Dumas), 490, 944946

Countdown latches, 936

CountDownLatch class, 935936

Covariant return types, 429

create method

of EventHandler, 598

of PersistenceService, 831, 837

createCustomCursor method (Toolkit), 618, 623

createDialog method (JColorChooser), 770

createFont method (Font), 575

createScreenCapture method (Robot), 778

createTypeBorder methods (BorderFactory), 664667

createXxxGroup methods (GroupLayout), 722

Ctrl+\, for thread dump, 889

Ctrl+C, for program termination, 863, 875

Ctrl+O, Ctrl+S accelerators, 687

Ctrl+Shift+F1, in Swing, 770

Ctrl+Tab, in text fields, 729

current method (ThreadLocalRandom), 893

Current user, 794

currentThread method (Thread), 851854

Cursor class, getPredefinedCursor method, 617

Cursor shapes, 618

Custom layout managers, 724728

Customizations. See Preferences

CyclicBarrier class, 935937

D

D suffix (double numbers), 49

Daemon threads, 859

darker method (Color), 571

Data exchange, 746752

Data fields

initializing, 176181

public, 150

Data types, 4753

boolean type, 52

casting between, 6061

char type, 5051

conversions between, 5960, 219221

floating-point, 4849

integer, 4748

Databases, closing connections to, 372

dataExchange/DataExchangeFrame.java, 748

dataExchange/PasswordChooser.java, 749

Date and time

formatting output for, 8384

no built-in types for, 136

Date class, 140

getDay/Month/Year methods (deprecated), 141

toString method, 137

DateInterval class, 428

Deadlocks, 874, 889892, 896

breaking up, 893

in GUI, 897

Debugging, 8, 409414

applets, 807

AWT events, 771, 774778

collections, 479

debuggers for, 409

generic types, 513

GUI programs, 367, 770778

including class names in, 344

intermittent bugs, 69, 545, 952

messages for, 366

reflection for, 272

trapping program errors in a file for, 411

when running applications in terminal window, 2526

DebugGraphics class, 771

Decorator design pattern, 631

Decrement operators, 6162

Deep copies, 308

deepToString method (Arrays), 122, 240

Default methods, 298300

resolving conflicts in, 300302

Default packages, 185

default statement, 104, 298300

DefaultButtonModel class, 636

DefaultComboBoxModel class, 669

Deferred execution, 325

delay method (Robot), 778

Delayed interface, 900

getDelay method, 900, 903

DelayQueue class, 900, 903

Delegates, 280

delete method

of PersistenceService, 838

of StringBuilder, 78

Dependence, 133135

Deprecated classes, 197

Deprecated methods, 141, 197, 412

Deprecated variables, 197

@deprecated comment (javadoc), 197

Deque interface, 494495

addFirst/Last methods, 494

getFirst/Last methods, 495

offerFirst/Last methods, 494

peekFirst/Last methods, 495

pollFirst/Last methods, 495

removeFirst/Last methods, 495

Deques, 494495

Derived classes. See Subclasses

deriveFont method (Font), 575, 581

Descender, descent (in typesetting), 576

descendingIterator method (NavigableSet), 493

Design patterns, 630632

Design Patterns—Elements of Reusable Object-Oriented Software (Gamma et al.), 632

destroy method (Applet), 808

Determinate loops, 99103

Development environments

choosing, 2326

in terminal window, 25

integrated, 2630

Device errors, 359

dialog/AboutDialog.java, 744

dialog/DialogFrame.java, 743

Dialogs, 730770

accepting/canceling, 746

centering, 304

closing, 603607, 688, 743, 746

color choosers, 764770

confirmation, 733

creating, 741745

data exchange in, 746752

default button in, 748

displaying, 743

document- and toolkit-modal, 742

file, 752764

input, 733

maximized, 603

modal, 730741

modeless, 730, 742743

data exchange with, 747

option, 731741

pop-up, 821

root pane of, 748

traversal order of, 729730

Diamond syntax, 245

Dijkstra, Edsger, 935

disjoint method (Collections), 524

divide method (BigDecimal, BigInteger), 110111

Division operator, 56

do/while loop, 96, 99

Doclets, 199

Documentation comments, 46, 194199

extracting, 198199

for fields, 196

for methods, 195196

for packages, 198

general, 196

HTML markup in, 194

hyperlinks in, 198

inserting, 194195

links to other files in, 195

overview, 198

Document-modal dialogs, 742

doInBackground method (SwingWorker), 944945, 950

Do-nothing methods, 604

Double brace initialization, 344

Double buffering, 771

Double class

compare method, 294

converting from double, 252

hashCode method, 237

POSITIVE_INFINITY, NEGATIVE_INFINITY, NaN constants, 49

double type, 48

arithmetic computations with, 56

converting to other numeric types, 5960

DoubleAccumulator, DoubleAdder classes, 889

Double-precision numbers, 4849

Doubly linked lists, 474

draw method (Graphics2D), 561

draw/DrawTest.java, 566

drawImage method (Graphics), 582, 585

Drawing with mouse, 616624

drawString method (Graphics/Graphics2D), 581

Drop-down lists, 668

Dynamic binding, 209, 214217

Dynamic languages, 8

E

e (exponent), in numbers, 49

E

as type variable, 419

constant (Math), 58

Echo character, 652653

Eclipse, 24, 2630, 409

configuring projects in, 28

editing source files in, 29

error messages in, 2930

imports in, 183

SWT toolkit, 543

ECMA-262 (JavaScript subset), 15

Eiffel programming language, multiple inheritance in, 297

element method

of BlockingQueue, 898899

of Queue, 494

elements method (Hashtable, Vector), 530

Ellington, Duke, 539

Ellipse2D class, 560, 564565

setFrameFromCenter method, 565

setFrameFromDiagonal method, 564

Ellipse2D.Double class, 569

Ellipses, 560, 564565

bounding rectangles of, 563565

constructing, 565

filling with color, 569

else statement, 9293

else if statement, 9394

EmployeeTest/EmployeeTest.java, 147

emptyCollection methods (Collections), 515

EmptyStackException, 381, 383

Encapsulation, 131132

benefits of, 153156

protected instance fields and, 284

endsWith method (String), 72

ensureCapacity method (ArrayList), 246247

entering method (Logger), 405

Enterprise Edition (Java EE), 11, 18

entrySet method (Map), 502503

Enum class, 258260

compareTo, ordinal methods, 260

toString, valueOf methods, 258, 260

enum keyword, 65

Enumerated types, 65

equality testing for, 258

in switch statement, 105

Enumeration interface, 460, 528530

nextElement, hasMoreElements methods, 465, 528, 530

Enumeration maps/sets, 506

Enumerations, 258260, 818

legacy, 528530

EnumMap class, 506, 508

as a concrete collection type, 472

enums/EnumTest.java, 259

EnumSet class, 506

allOf, noneOf, of, range methods, 508

as a concrete collection type, 472

EOFException, 364

Epoch, 139

equals method, 302

for wrappers, 254

hashCode method and, 236237

implementing, 233

inheritance and, 231235

of Arrays, 120, 234

of Collection, 467

of Object, 229235, 244, 512

of proxy classes, 355

of Set, 471

of String, 68, 72

redefining, 236237

equals/Employee.java, 241

equals/EqualsTest.java, 240

equals/Manager.java, 243

equalsIgnoreCase method (String), 68, 72

Error class, 360

Errors

checking, in mutator methods, 154

code, 359

compilation, 29

device, 359

internal, 360, 363, 386

messages for, 369

NoClassDefFoundError, 26

physical limitations, 359

ThreadDeath, 857, 862, 896

user input, 359

Escape sequences, 50

Event delegation model, 588

Event dispatch thread, 545, 846, 897

time-consuming tasks and, 939

Event handling, 587628

defined, 587

for asynchronous actions, 931

semantic vs. low-level events, 626

summary of, 626628

Event listeners, 588589

with a single method call, 597

with lambda expressions, 595

Event objects, 588

Event procedures, 587

Event sources, 588589

EventHandler class

create method, 598

creating listeners automatically with, 597

EventObject class, 588, 624

getActionCommand method, 624

getSource method, 598, 624

EventQueue class

invokeAndWait method, 940, 943

invokeLater method, 940, 943, 952

isDispatchThread method, 943

eventTracer/EventTracer.java, 772

ExampleFileView class, 757

Exception class, 360, 380

Exception handlers, 263, 359

Exception specification, 362

Exceptions

ArrayIndexOutOfBoundsException, 112, 361363, 938

ArrayStoreException, 431, 433, 441

BadCastException, 451

BrokenBarrierException, 937

CancellationException, 945

catching, 263265, 363, 367381

multiple, 369370

changing type of, 370

checked, 261264, 361364, 383

ClassCastException, 220, 276, 295, 435, 441, 513

classification of, 359361

CloneNotSupportedException, 310

ConcurrentModificationException, 478479, 906, 914

creating classes for, 365366

documentation comments for, 196

EmptyStackException, 381, 383

EOFException, 364

FileNotFoundException, 362364, 438

finally clause in, 372376

generics in, 437439

hierarchy of, 359, 383

IllegalAccessException, 272

IllegalStateException, 465, 469, 483, 494, 899

InterruptedException, 841, 847, 851854, 893895, 915

IOException, 88, 361, 364, 368, 375

logging, 392, 400

micromanaging, 381

NoSuchElementException, 464, 469, 483, 494495

NullPointerException, 361, 383

NumberFormatException, 383

propagating, 368, 384

rethrowing and chaining, 370, 410

RuntimeException, 360, 383

ServletException, 370

squelching, 383

stack trace for, 377381

“throw early, catch late,” 384

throwing, 263265, 364365

TimeoutException, 915

tips for using, 381384

UnavailableServiceException, 830

uncaught, 411, 857, 860862

unchecked, 264, 361363, 383

unexpected, 392, 400

UnsupportedOperationException, 503, 510, 512, 514

using type variables in, 437

variables for, implicitly final, 370

vs. simple tests, 381

wrapping, 371

Exchanger class, 935, 937

Exchangers, 937

.exe file extension, 783

Executable JAR files, 782783

Executable path, 20

execute method (SwingWorker), 945, 950

Execution flow, tracing, 391

ExecutionException, 933

ExecutorCompletionService class, 927

poll, submit, take methods, 928

Executors, 920934

groups of tasks, controlling, 927928

scheduled, 926

Executors class

newCachedThreadPool method, 921, 925

newFixedThreadPool method, 921, 925

newScheduledThreadPool method, 921, 926

newSingleThreadExecutor method, 921, 925

newSingleThreadScheduledExecutor method, 921, 926

ExecutorService interface, 921922

invokeAny/All methods, 927928

shutdown method, 922, 925

shutdownNow method, 922, 927

submit method, 921, 925

Exit codes, 45

exit method (System), 45

exiting method (Logger), 391, 405

exp method (Math), 58

Explicit parameters, 152153

exportXxx methods (Preferences), 795, 800

ExtendedService class, 830

extends keyword, 204228, 422423

External padding, 704

F

F suffix (float numbers), 49

Factorial functions, 378

Factory methods, 161

Fair locks, 872

Fallthrough behavior, 105, 412

fdlibm (Freely Distributable Math Library), 59

Field class, 265

get method, 276

getDeclaringClass method, 270

getModifiers method, 265, 270

getName method, 265, 270

getType method, 265

set method, 276

Field width, of numbers, 82

Fields

adding, in subclasses, 207

default initialization of, 172173

documentation comments for, 194, 196

final, 159, 218

instance, 131, 150153, 157, 174, 200

private, 200, 206

protected, 194, 228, 283

public, 194, 196

public static final, 296

static, 158159, 178, 185, 436

volatile, 885886

File access warning, 831

File dialogs, 752764

adding accessory components to, 757

fileChooser/FileIconView.java, 762

fileChooser/ImagePreviewer.java, 761

fileChooser/ImageViewerFrame.java, 759

FileContents class

canRead/Write methods, 837

getName method, 837

getXxxStream methods, 830, 837

FileFilter class (Swing)

accept method, 755, 764

getDescription method, 755, 764

FileFilter interface (java.io package), 755

FileHandler class, 394399, 407

configuration parameters of, 396

FileNameExtensionFilter interface, 764

FileNotFoundException, 362364, 438

FileOpenService class

openFileDialog method, 830, 837

openMultiFileDialog method, 837

Files

extensions of, 757

filters for, 755757

MIME types of, 825

names of, 25, 87

opening/saving in GUI, 752764

reading, 87

all words from, 376

in a separate thread, 944

writing, 87

FileSaveService class

saveAsFileDialog method, 837

saveFileDialog method, 830, 837

FileView class, 756

getIcon, getName, getDescription, getTypeDescription methods, 756, 764

isTraversable method, 756, 764

fill method

of Arrays, 120

of Collections, 523

of Graphics2D, 569570, 573

Filter interface, 398

isLoggable method, 398, 408

final access modifier, 55, 217218

checking, 265

for fields in interfaces, 296

for instance fields, 157

for methods in superclass, 295

for shared fields, 886

inner classes and, 339342

finalize method, 181182

finally clause, 372376

not completed normally, 412

return statements in, 374

unlock operation in, 869

without catch, 373

Financial calculations, 49

fine, finer, finest methods (Logger), 390, 404

Firefox, 34

first method (SortedSet), 493

First Person, Inc., 10

firstKey method (SortedMap), 500

FirstSample/FirstSample.java, 46

Float class

converting from float, 252

hashCode method, 237

POSITIVE_INFINITY, NEGATIVE_INFINITY, NaN constants, 49

float type, 48

converting to other numeric types, 5960

Floating-point numbers, 4849

arithmetic computations with, 56

equality of, 101

formatting output for, 8283

rounding, 49, 60

Floating-point overflow, 57

floor method (NavigableSet), 493

floorMod method (Math), 57

Flow layout manager, 638

FlowLayout class, 641

flush method (Handler), 406

FocusAdapter class, 626

FocusEvent class, 626

isTemporary method, 627

FocusListener interface, 626

focusGained/Lost methods, 627

Font class, 574581

createFont method, 575

deriveFont method, 575, 581

getFamily, getFontName, getName methods, 580

getLineMetrics method, 577, 580

getStringBounds method, 576577, 580

font/FontTest.java, 578

fontconfig.properties file, 575

FontMetrics class, getFontRenderContext method, 582

Fonts, 573582

checking availability of, 573

face/family names of, 573

logical names of, 574

size of, 574575

styles of, 575

typesetting properties of, 576

“for each” loop, 112114

for array lists, 249

for collections, 464, 914

for multidimensional arrays, 122

for loop, 99103

comma-separated lists of expressions in, 65

defining variables inside, 101

for collections, 464

forEach method

of ConcurrentHashMap, 910911

of Map, 499

Foreground color, specifying, 570

Fork-join framework, 928

forkJoin/ForkJoinTest.java, 930

Format specifiers (printf), 82

format, formatTo methods (String), 83

Formattable interface, 83

Formatter class, methods of, 399, 408

forName method (Class), 261, 265

Frame class, 543

get/setExtendedState method, 553

getIconImage method, 553

getTitle method, 553

is/setUndecorated methods, 553

isResizable method, 553

setIconImage method, 546, 553

setResizable method, 546, 553

setTitle method, 546, 553

Frames

closing by user, 545

creating, 543546

decorating, 546

displaying:

information in, 554560

text in, 557

positioning, 546554

properties of, 549

size of, 549554

frequency method (Collections), 524

Full-screen mode, 550

Function interface, 326

Functional interfaces, 318319

abstract methods in, 318

annotating, 328

conversion to, 318

generic, 319

using supertype bounds in, 447

@FunctionalInterface annotation, 328

Functions. See Methods

Future interface, 927

cancel method, 915, 920921, 945

get method, 915, 919, 921, 945

isCancelled, isDone methods, 915, 920921

future/FutureTest.java, 917

Futures, 915920

combining multiple, 934

completable, 931934

FutureTask class, 915920

G

Garbage collection, 68, 139

hash maps and, 504

GB18030 standard, 51

General Public License (GPL), 14

Generic programming, 415458

classes in, 245, 418420, 669

extending/implementing other generic classes, 441

no throwing or catching instances of, 436437

collection interfaces in, 525

converting to raw types, 412, 441

debugging, 513

expressions in, 426

in JVM, 425, 452458

inheritance rules for, 440442

legacy code and, 429

methods in, 421422, 427429, 466469

not for arrays, 434436

reflection and, 450458

required skill levels for, 417

static fields or methods and, 436

type erasure in, 425430, 434

clashes after, 439440

type matching in, 452

vs. arrays, 321

vs. inheritance, 416418

wildcard types in, 442450

GenericArrayType interface, 453

getGenericComponentType method, 458

genericReflection/GenericReflectionTest.java, 454

get method

of Array, 279

of ArrayList, 247, 251

of BitSet, 533

of ConcurrentHashMap, 908

of Field, 276

of Future, 915, 919, 921, 945

of LinkedList, 480

of List, 470, 483

of LongAccumulator, 888

of Map, 469, 497, 499

of PersistenceService, 838

of Preferences, 795, 800

of ThreadLocal, 893

of Vector, 883

getActionCommand method

of ActionEvent, 598, 627

of ButtonModel, 661, 663

of EventObject, 624

getActionMap method (JComponent), 615

getActualTypeArguments method (ParameterizedType), 458

getAdjustable, getAdjustmentType methods (AdjustmentEvent), 627

getAncestorOfClass method (SwingUtilities), 747, 752

getAndType methods (AtomicType), 887

getApplet, getApplets methods (AppletContext), 818, 820

getAppletContext method (Applet), 818820

getAppletInfo method (Applet), 816

getAscent method (LineMetrics), 581

getAudioClip method (Class), 784, 817

getAutoCreateXxx methods (GroupLayout), 722

getAvailableFontFamilyNames method (GraphicsEnvironment), 573

getBackground method (Component), 573

getBoolean method (Array), 279

getBounds method (TypeVariable), 457

getByte method (Array), 279

getCause method (Throwable), 379

getCenterX/Y methods (RectangularShape), 563, 568

getChar method (Array), 279

getClass method

always returning raw types, 431

of Class, 261

of Object, 244

getClassName method

of LookAndFeelInfo, 603

of StackTraceElement, 380

getClickCount method (MouseEvent), 616, 623, 627

getCodeBase method

of Applet, 816817

of BasicService, 831, 836

getColor method

of Graphics, 572

of JColorChooser, 770

getColumns method (JTextField), 650

getComponentPopupMenu method (JComponent), 686

getComponentType method (Class), 277

getConstructor method (Class), 451

getConstructors method (Class), 266, 270

getContentPane method (JFrame), 559

getDataType methods (Preferences), 795, 800

getDay method (Date, deprecated), 141

getDayXxx methods (LocalDate), 141, 145

getDeclaredConstructor method (Class), 451

getDeclaredConstructors method (Class), 266, 270

getDeclaredField method (Class), 275

getDeclaredFields method (Class), 266, 270, 272, 275

getDeclaredMethods method (Class), 266, 270, 280

getDeclaringClass method (java.lang.reflect), 270

getDefaultScreenDevice method (GraphicsEnvironment), 774, 778

getDefaultToolkit method (Toolkit), 305, 549, 553

getDefaultUncaughtExceptionHandler method (Thread), 861

getDelay method (Delayed), 900, 903

getDescent method (LineMetrics), 581

getDescription method

of FileFilter, 755, 764

of FileView, 756, 764

getDocumentBase method (Applet), 816817

getDouble method (Array), 279

getEnumConstants method (Class), 451

getExceptionTypes method (Constructor), 270

getExtendedState method (Frame), 553

getFamily method (Font), 580

getField method (Class), 275

getFields method (Class), 266, 270, 275

getFileName method (StackTraceElement), 380

getFilter method (Handler, Logger), 406

getFirst/Last methods

of Deque, 495

of LinkedList, 484

getFloat method (Array), 279

getFont method

of Component, 651

of Graphics, 581

getFontMetrics method (JComponent), 577, 582

getFontName method (Font), 580

getFontRenderContext method

of FontMetrics, 582

of Graphics2D, 576, 582

getForeground method (Component), 573

getFormatter method (Handler), 406

getGenericComponentType method (GenericArrayType), 458

getGenericParameterTypes, getGenericReturnType methods (Method), 457

getGenericXxx methods (Class), 457

getGlobal method (Logger), 389, 410

getHandlers method (Logger), 406

getHead method (Formatter), 399, 408

getHeight method

of LineMetrics, 581

of RectangularShape, 563, 568

getHonorsVisibility, getHorizontalGroup methods (GroupLayout), 722

getIcon method

of FileView, 756, 764

of JLabel, 652

getIconImage method (Frame), 553

getImage method

of Applet, 817

of Class, 784

of ImageIcon, 554, 582

getInheritsPopupMenu method (JComponent), 686

getInputMap method (JComponent), 612, 615

getInputStream method (FileContents), 830, 837

getInstalledLookAndFeels method (UIManager), 602

getInt method (Array), 279

getItem, getItemSelectable methods (ItemEvent), 627

getItemAt method (JComboBox), 669

getKey method (Map.Entry), 503

getKeyStroke method (KeyStroke), 610, 615

getKeyXxx methods (KeyEvent), 627

getLargestPoolSize method (ThreadPoolExecutor), 926

getLeading method (LineMetrics), 581

getLength method (Array), 277, 279

getLevel method

of Handler, 406

of Logger, 405

of LogRecord, 407

getLineMetrics method (Font), 577, 580

getLineNumber method (StackTraceElement), 380

getLocalGraphicsEnvironment method (GraphicsEnvironment), 774, 778

getLogger method (Logger), 390, 404

getLoggerName method (LogRecord), 407

getLong method (Array), 279

getLowerBounds method (WildcardType), 458

getMaxX/Y methods (RectangularShape), 568

getMessage method

of LogRecord, 407

of Throwable, 366

getMethod method (Class), 280

getMethodName method (StackTraceElement), 380

getMethods method (Class), 266, 270

getMillis method (LogRecord), 408

getMinX/Y methods (RectangularShape), 568

getModifiers method

of ActionEvent, 627

of java.lang.reflect, 265, 270

getModifiersEx method (InputEvent), 617, 623

getModifiersExText method (InputEvent), 623

getMonth method (Date, deprecated), 141

getMonthXxx methods (LocalDate), 141, 145

getName method

of Class, 244, 261262

of FileContents, 837

of FileView, 756, 764

of Font, 580

of java.lang.reflect, 265, 270

of LookAndFeelInfo, 603

of TypeVariable, 457

getNames method (PersistenceService), 838

getNewState, getOldState methods (WindowEvent), 607, 628

getOppositeWindow method (WindowEvent), 628

getOrDefault method (Map), 499

getOutputStream method (FileContents), 830, 837

getOwnerType method (ParameterizedType), 458

getPaint method (Graphics2D), 573

getParameter method (Applet), 810811, 816

getParameterInfo method (Applet), 816

getParameters method (LogRecord), 407

getParameterTypes method (Method), 270

getParent method (Logger), 406

getPassword method (JPasswordField), 653

getPoint method (MouseEvent), 623, 627

getPredefinedCursor method (Cursor), 617

getPreferredSize method (Component), 557, 559

getProperties method (System), 789, 793

getProperty method

of Properties, 531, 789, 792

of System, 793

getProxyClass method (Proxy), 355356

getRawType method (ParameterizedType), 458

getResource, getResourceAsStream methods (Class), 784, 787

getResourceBundle, getResourceBundleName methods (LogRecord), 407

getReturnType method (Method), 270

getRootPane method (JComponent), 748, 752

getScreenSize method (Toolkit), 549, 553

getScrollAmount method (MouseWheelEvent), 628

getSelectedFile/Files methods (JFileChooser), 754, 763

getSelectedItem method (JComboBox), 669671

getSelectedObjects method (ItemSelectable), 661

getSelection method (ButtonGroup), 661, 663

getSequenceNumber method (LogRecord), 408

getServiceNames method (ServiceManager), 836

getShort method (Array), 279

getSize method (Component), 552

getSource method (EventObject), 598, 624

getSourceXxxName methods (LogRecord), 408

getStackTrace method (Throwable), 377, 379

getState method

of SwingWorker, 950

of Thread, 858

getStateChange method (ItemEvent), 627

getStringBounds method (Font), 576577, 580

getSuperclass method (Class), 244, 451

getSuppressed method (Throwable), 377, 380

getTail method (Formatter), 399, 408

Getter/setter pairs. See Properties

getText method

of JLabel, 652

of JTextComponent, 650

getThreadID method (LogRecord), 408

getThrown method (LogRecord), 408

getTime method (Calendar), 218

getTitle method (Frame), 553

getType method (Field), 265

getTypeDescription method (FileView), 756, 764

getTypeParameters method (Class, Method), 457

getUncaughtExceptionHandler method (Thread), 861

getUpperBounds method (WildcardType), 458

getUseParentHandlers method (Logger), 406

getValue method

of Action, 608, 615

of AdjustmentEvent, 627

of Map.Entry, 503

getWheelRotation method (MouseWheelEvent), 628

getWidth method

of Rectangle2D, 563

of RectangularShape, 563, 568

getWindow method (WindowEvent), 628

getX/Y methods

of MouseEvent, 616, 623, 627

of RectangularShape, 568

getYear method

of Date (deprecated), 141

of LocalDate, 141, 145

GMT (Greenwich Mean Time), 139

Goetz, Brian, 840, 885

Gosling, James, 1011

goto statement, 89, 106

Graphical User Interface (GUI), 537586

automatic testing, 774778

components of, 629778

choice components, 657678

dialog boxes, 730770

text input, 648656

toolbars, 694696

tooltips, 696699

traversal order of, 729730

deadlocks in, 897

debugging, 367, 770778

events in, 587

keyboard focus in, 611

layout of, 638648, 699730

multithreading for, 846851

Graphics class, 560, 582586

copyArea method, 583, 586

drawImage method, 582, 585

drawString method, 581

get/setFont methods, 581

getColor method, 572

setColor method, 570, 572

Graphics editor applications, 616624

Graphics2D class, 560569

draw method, 561

drawString method, 582

fill method, 569570, 573

getFontRenderContext method, 576, 582

getPaint method, 573

setPaint method, 569, 573

GraphicsDevice class, 550, 774

GraphicsEnvironment class, 550

getAvailableFontFamilyNames method, 573

getDefaultScreenDevice method, 774, 778

getLocalGraphicsEnvironment method, 774, 778

Green project, 10

GregorianCalendar class, 142

add method, 142

constructors for, 140, 172

Grid bag layout, 700712

padding in, 704

Grid layout, 644648

gridbag/FontFrame.java, 707

gridbag/GBC.java, 709

GridBagConstraints class, 703

fill, anchor parameters, 704, 712

gridx/y, gridwidth/height parameters, 703706, 712

helper class for, 706712

insets field, 704, 712

ipadx/y parameters, 712

weightx/y fields, 703, 712

GridLayout class, 641, 644648

Group layout, 701, 713723

GroupLayout class, 713723

methods of, 722

groupLayout/FontFrame.java, 719

GroupLayout.Group class, 723

GroupLayout.ParallelGroup class, 723

GroupLayout.SequentialGroup class, 723

GTK look-and-feel, 539540

GUI. See Graphical User Interface

H

handle method (CompletableFuture), 933

Handler class, 397

close method, 406

flush method, 406

get/setFilter methods, 406

get/setLevel methods, 406

getFormatter method, 406

publish method, 398, 406

setFormatter method, 399, 406

Handlers, 394398

Hansen, Per Brinch, 884

“Has–a” relationship, 133135

hash method (Objects), 237

Hash codes, 235238, 485

default, 235

formatting output for, 83

Hash collisions, 486

Hash maps, 497

concurrent, 905907

identity, 507509

linked, 504506

setting, 497

vs. tree maps, 497

weak, 504

Hash sets, 485489

adding elements to, 490

linked, 504506

Hash tables, 485

legacy, 528

load factor of, 486

rehashing, 486

hashCode method, 235238

equals method and, 236237

null-safe, 236

of Arrays, 238

of Boolean, Byte, Character, Double, Float, Integer, Long, Short, 237

of Object, 237, 489

of Objects, 236237

of proxy classes, 355

of Set, 471

of String, 485

HashMap class, 497, 500

as a concrete collection type, 472

HashSet class, 464, 487488

add method, 487

as a concrete collection type, 472

contains method, 487

Hashtable interface, 460, 528, 914915

as a concrete collection type, 472

elements, keys methods, 530

synchronized methods, 528

hasMoreElements method (Enumeration), 465, 528, 530

hasNext method

of Iterator, 463, 465, 469

of Scanner, 81

hasNextType methods (Scanner), 81

hasPrevious method (ListIterator), 476, 483

headMap method

of NavigableMap, 517

of SortedMap, 511, 516

headSet method (NavigableSet, SortedSet), 511, 516

Heap, 495

dumping, 413

Height (in typesetting), 576

Helper classes, 706712

Helper methods, 156, 448

Hexadecimal numbers

formatting output for, 8283

prefix for, 48

higher method (NavigableSet), 493

Hoare, Tony, 884

Hold count, 870

Holder types, 255

HotJava browser, 11, 802

Hotspot just-in-time compiler, 534

HTML (HyperText Markup Language), 1213

applet element, 34, 805, 808810

param element, 810816

tables, 701

target attribute, 820

title element, 807

HTML editors, 633

I

Icons

associating with file extensions, 757

in menu items, 682683

in sliders, 674

Identity hash maps, 507509

identityHashCode method (System), 507, 509

IdentityHashMap class, 507509

as a concrete collection type, 472

IEEE 754 specification, 49, 59

if statement, 9094

IFC (Internet Foundation Classes), 538

IllegalAccessException, 272

IllegalStateException, 465, 469, 483, 494, 899

image/ImageTest.java, 583

ImageIcon class, 550

getImage method, 554, 582

Images

accessing from applets, 816817

displaying, 582586

ImageViewer/ImageViewer.java, 31

Immutable classes, 157

Implementations, 460

implements keyword, 290

Implicit parameters, 152153

none, in static methods, 160

state of, 409

import statement, 183184

static, 185

importPreferences method (Preferences), 795, 800

Inconsistent state, 896

increment method (LongAdder), 888

Increment operators, 6162

Incremental linking, 7

incrementAndGet method (AtomicType), 887

Index (in arrays), 111

indexOf method

of List, 483

of String, 73

indexOfSubList method (Collections), 524

info method (Logger), 389390, 404

Information hiding. See Encapsulation

Inheritance, 133135, 203286

design hints for, 283286

equality testing and, 231235

hierarchies of, 212213

multiple, 213, 297

preventing, 217218

vs. type parameters, 416, 440442

inheritance/Employee.java, 210

inheritance/Manager.java, 211

inheritance/ManagerTest.java, 210

init method (Applet), 807, 811

initCause method (Throwable), 379

Initialization blocks, 177181

static, 178

initialize method (ThreadLocal), 893

Inlining, 7, 218

Inner classes, 329349

accessing object state with, 331334

anonymous, 329, 342345, 606

applicability of, 335338

defined, 329

local, 339

private, 333

static, 331, 346349

syntax of, 334335

vs. lambdas, 318

innerClass/InnerClassTest.java, 333

Input dialogs, 733

Input maps, 611613

Input, reading, 7981

InputEvent class

getModifiersEx method, 617, 623

getModifiersExText method, 623

InputTest/InputTest.java, 80

insert method

of JMenu, 681

of JTextArea, 951

of StringBuilder, 78

insertItemAt method (JComboBox), 669, 671

insertSeparator method (JMenu), 681

Instance fields, 131

final, 157

initializing, 200

explicit, 174

not present in interfaces, 289, 296

private, 150, 200

protected, 283

public, 150

shadowing, 151, 175176

values of, 153154

volatile, 885886

vs. local variables, 151152, 173

instanceof operator, 64, 220221, 295

Instances, 131

creating on the fly, 263

int type, 47

converting to other numeric types, 5960

fixed size for, 6

platform-independence of, 48

random number generator for, 181

Integer class

compare method, 294, 318

converting from int, 252

hashCode method, 237

intValue method, 255

parseInt method, 254, 256, 811

toString method, 256

valueOf method, 256

Integer types, 4748

arithmetic computations with, 56

arrays of, 240

formatting output for, 82

no unsigned types in Java, 48

Integrated Development Environment (IDE), 20, 2630

Inter-applet communication, 810, 818

interface keyword, 288

Interface types, 462

Interface variables, 295

Interfaces, 288305

abstract classes and, 297

callbacks and, 302305

constants in, 296

defined, 288

documentation comments for, 194

evolution of, 299

extending, 295

for custom algorithms, 526528

functional, 318319

listener, 588

marker, 309

methods in, 298

clashes between, 300302

do-nothing, 604

nonabstract, 318

no instance fields in, 289, 296

properties of, 295296

public, 194

tagging, 309, 426, 471

vs. implementations, 460463

interfaces/Employee.java, 293

interfaces/EmployeeSortTest.java, 292

Intermittent bugs, 69, 545, 952

Internal errors, 360, 363, 386

Internal padding, 704

Internationalization. See Localization

Internet Explorer

applets in, 810

Java in, 9

limited Java support in, 803

security of, 15

Interpreted languages, 14

Interpreter, 7

interrupt method (Thread), 851854

interrupted method (Thread), 853854

InterruptedException, 841, 847, 851854, 893895, 915

IntHolder class, 255

Intrinsic locks, 878, 884

Introduction to Algorithms (Cormen et al.), 489

intValue method (Integer), 255

Invocation handlers, 350

InvocationHandler interface, 350, 355

invoke method

of InvocationHandler, 350, 355

of Method, 279283

invokeAndWait method (EventQueue), 940, 943

invokeAny/All methods (ExecutorService), 927928

invokeLater method (EventQueue), 940, 943, 952

IOException, 88, 361, 364, 368, 375

“Is–a” relationship, 133135, 213, 284

isAbstract method (Modifier), 271

isAccessible method (AccessibleObject), 275

isActionKey method (KeyEvent), 627

isCancelled, isDone methods (Future), 915, 920921

isDefaultButton method (JButton), 752

isDispatchThread method (EventQueue), 943

isEditable method

of JComboBox, 671

of JTextComponent, 648

isEmpty method (Collection), 299, 467468

isEnabled method (Action), 608, 615

isFinal method (Modifier), 265, 271

isInterface method (Modifier), 271

isInterrupted method (Thread), 851854

isJavaIdentifierXxx methods (Character), 53

isLocationByPlatform method (Window), 552

isLoggable method (Filter), 398, 408

isNaN method (Double), 49

isNative method (Modifier), 271

isNativeMethod method (StackTraceElement), 381

ISO 8859–1 standard, 51

isPopupTrigger method

of JPopupMenu, 685

of MouseEvent, 686

isPrivate method (Modifier), 265, 271

isProtected method (Modifier), 271

isProxyClass method (Proxy), 355356

isPublic method (Modifier), 265, 271

isResizable method (Frame), 553

isSelected method

of AbstractButton, 684

of JCheckBox, 658659

isStatic, isStrict, isSynchronized methods (Modifier), 271

isTemporary method (FocusEvent), 627

isTraversable method (FileView), 756, 764

isUndecorated method (Frame), 553

isVisible method (Component), 552

isVolatile method (Modifier), 271

isWebBrowserSupported method (BasicService), 836

ItemEvent class, 626

getItem, getItemSelectable, getStateChange methods, 627

ItemListener interface, 626

itemStateChanged method, 627

ItemSelectable interface, getSelectedObjects method, 661

Iterable interface, 113

iterator method

of Collection, 463, 468

of ServiceLoader, 802

Iterator interface, 463466

“for each” loop, 464

generic, 466

hasNext, next, remove methods, 463, 465, 469

Iterators, 463466

being between elements, 465

weakly consistent, 906

IzPack utility, 783