J
J2SE 5, features added by, 16
[Link] package, 1161, 1162–1166, 1168
classes, list of core, 1165
interfaces, list of core, 1162
[Link] package, 1162, 1168–1173
interfaces and classes, list of some, 1168
JApplet class, 1065
JAR files. See Java Archive (JAR) files
jar tool, 447
Java
and C, 3, 5, 7, 13
and C++, 3, 7–8, 13
and C#, 8
design features (buzzwords), 13–15
history of, 3, 6–8, 15–20
incubator modules, 480
and the Internet, 3, 6, 7–10, 14, 20, 795
as an interpreted language, 10, 14–15
keywords. See Keywords
look and feels, 1063
open-source implementations of, 20, 27
preview features, 480
release schedule, 12, 19
as a strongly typed language, 14, 39, 45
versions of, 15–20, 535–536
and the World Wide Web, 7, 13
Java Archive (JAR) files, 448, 707
modular, 447
Java Beans, 547, 569, 1031, 1040, 1145–1155
advantages of, 1146
API, 1150–1152
customizers, 1149
definition of the term, 1145
demonstration program, 1152–1155
events, design pattern for, 1148
introspection, 1146–1149, 1152, 1154–1155
persistence, 1149
properties. See Property, Java Bean
serialization, 1149
Java Community Process (JCP), 20
.java filename extension, 27, 1201
Java Foundation Classes (JFC), 1062
java (Java application launcher), 28, 29, 201, 324, 448, 1201, 1202
and main( ), 29
and modules, 421, 427, 448
java package, 201, 207
Java Runtime Environment (JRE), 10, 11, 429
Java SE 7, 17–18
Java SE 8, 18
Java SE 9, 18–19
Java SE 10, 19
Java SE 11, 19
Java Virtual Machine (JVM), 10, 11, 14, 15, 20, 28, 29, 532, 554, 568
Java Web Start, 11, 19
[Link] package, 819, 822, 852, 930, 1072
classes, tables of some, 852–854
[Link] class, reflection example using the, 1040–1041
[Link] package, 819, 821, 822, 833, 844, 1071, 1072
adapter classes, table of commonly used, 845
event classes, table of commonly used, 823
interfaces, table of commonly used, 833
[Link] class. See InputEvent class
[Link] class. See KeyEvent class
[Link] package, 929, 935, 940, 951, 954
[Link] module, 429, 511, 568, 571, 707, 763, 797, 819, 852, 956, 1006,
1031, 1040, 1047, 1052
[Link] package, 1148, 1150–1152
classes, table of, 1150–1151
interfaces in the, table of non-deprecated, 1150
[Link] module, 429, 819, 930, 1066, 1150
[Link] module, 568
[Link] package, 315, 316–318, 325, 330, 713–714, 720, 763, 787
automatically imported by JShell, 1199
classes, list of, 714. See also Streams, byte; Streams, character
interfaces, list of, 714
[Link] interface, 755, 1149
[Link]. See IOException
[Link] interface, 1149. See also Serializable interface
[Link] package, 207, 240, 296, 305, 318, 325, 330, 368, 371, 483, 429, 511–
569, 720
classes and interfaces, list of, 511
implicit importation of the, 207, 511
subpackages, 568–569
[Link] package, 295, 305, 312, 568
[Link] enumeration, 295, 568
[Link] package, 568
[Link] package, 937
[Link] package, 568
[Link] package, 568
[Link] package, 568
[Link] package, 562, 568, 569
[Link], 466
[Link] package, 568, 569
[Link] package, 296, 301, 568, 569, 1031, 1040
classes, table of, 1040
[Link] module, 568
[Link] package, 795, 808, 813
classes and interfaces, list of, 796–797
[Link], 19, 795, 813–818
[Link] package, 316, 713, 763, 764
[Link] package, 763, 767, 768
[Link] package, 763
[Link] package, 763, 768
[Link] package, 763
[Link] package, 717, 763, 768
[Link] package, 763, 768, 773
[Link] package, 763, 769
[Link], 794
[Link] module, 710
[Link] module, 1044
[Link] package, 1031, 1044
[Link] package, 1031, 1047
[Link] package, 662, 1031, 1051, 1052, 1057
[Link], 983, 1057
[Link] package, 1051, 1053, 1054
[Link], 983
[Link] package, 436, 571–572, 636, 653, 819, 822, 1011, 1026
automatically imported by JShell, 1199
classes, list of top-level, 571–572
interfaces defined by, list of, 572
subpackages, 707–711
[Link] package, 707, 956–957, 982, 988
[Link] package, 707, 956, 957, 986, 987
[Link] package, 707, 956, 957, 984, 985, 986
[Link] package, 18, 419, 567, 600, 618, 634, 653, 707, 1012, 1013,
1018, 1025
functional interfaces defined by, table of, 708–710
[Link] package, 707
[Link] class. See List class ([Link])
[Link] package, 707, 710
[Link] package, 707, 710
[Link] package, 707, 711
[Link] package, 707, 711, 1031
[Link] package, 707, 711
[Link] package, 18, 707, 711, 1006, 1022, 1030
[Link] package, 707, 711
[Link] module, 429
JAVA_HOME environmental variable, 446
javac (Java compiler), 27–28, 201, 308, 374, 1192, 1194, 1201, 1202
and modules, 421, 422, 426–427, 448
and multi-module compilation mode, 431
javadoc, 19, 1183–1189
tags, 1183–1189
JavaFX, 19, 837
javap, 385
[Link] package, 930, 954
[Link] package, 1162
[Link] package, 1064, 1066, 1068, 1069, 1079, 1102
classes, list of, 1064–1065
[Link] package, 1071, 1082, 1097, 1102
[Link] package, 1105
[Link] package, 1102
JButton class, 1065, 1073, 1079, 1083–1085, 1110, 1113, 1131
JCheckBox class, 1079, 1083, 1086, 1088–1089, 1131
JCheckBoxMenuItem class, 1110, 1121, 1122–1123, 1131
JComboBox class, 1079, 1099–1101
JComponent class, 1064, 1065, 1074, 1075, 1079, 1083, 1111, 1121
JDialog class, 1065, 1141
JFormattedTextField class, 1141
JFrame class, 1065, 1066–1067, 1068, 1069–1070, 1078
adding a menu bar to a, 1112, 1114, 1117
content pane layout manager, 1069, 1072–1073
JIT (Just-In-Time) compiler, 10, 14
JLabel class, 1065, 1066, 1067, 1069, 1071, 1074, 1079–1081, 1117
JLayeredPane class, 1066
jlink tool, 11, 18, 446–448
JList class, 1079, 1096–1099
JMenu class, 1110, 1111, 1112–1113, 1114
mnemonic, 1118
JMenuBar class, 1110, 1111–1112, 1114
JMenuItem class, 1110, 1111, 1112, 1113, 1114, 1121, 1122
accelerator key, 1119, 1120
action to create a, using an, 1131
and action events, 1113, 1114, 1117, 1118
mnemonic, 1118, 1119–1120
JMOD files, 18, 446, 447
join( ), 250, 258–260, 500–501, 555, 983, 989, 999, 1000, 1003
JOptionPane class, 1141
Joy, Bill, 6
jpackage tool, 11, 20, 448
JPanel class, 1065, 1066, 1076, 1078, 1092, 1094
JPEG image file format, 929
JPopupMenu class, 1110, 1123–1126, 1131
and mouse events, 1124, 1125–1126
JRadioButton class, 1079, 1083, 1086, 1089–1091, 1131
JRadioButtonMenuItem class, 1110, 1122–1123, 1131
JRootPane class, 1065
JScrollBar class, 1065
JSeparator class, 1110, 1112
JScrollPane class, 1079, 1094–1096, 1097, 1102, 1103, 1105
jshell, 1191
JShell, 19, 1191–1200
commands, 1194, 1199–1200
and state information, 1191, 1193
JSpinner class, 1141
JTabbedPane class, 1079, 1092–1094
JTable class, 1079, 1105–1107
JTextCompenent class, 1081
JTextField class, 1079, 1081–1083
JToggleButton class, 1079, 1083, 1085–1087, 1089
[Link] class, 1086
JToolbar class, 1110, 1127–1129
adding an action to a, 1131
JTree class, 1079, 1101–1104
Jump statements, 87, 109–115
Just In Time (JIT) compiler, 10, 14
JVM (Java Virtual Machine), 10, 11, 14, 15, 20, 28, 29, 532, 554, 568
JWindow class, 1065
Kernighan, Brian, 4
Key codes, virtual, 828, 842
KeyAdapter class, 845, 846
Keyboard events, handling, 840–844
KeyEvent class, 823, 825, 826, 828, 1118, 1119
KeyListener interface, 833, 834–835, 840–844, 845
keyPressed( ), 834–835, 840, 842
keyReleased( ), 834–835, 840
keys( ), 643, 644, 645
keySet( ), 605, 607, 646, 704, 808
KeyStroke class, 1119
keyTyped( ), 834–835, 840, 842
Keywords
context-sensitive, 37, 38, 63, 422
table of Java, 38
Label
AWT standard control, 880, 881–882
Swing, 1067, 1069, 1079–1081
used with break statement, 111–113
used with continue statement, 114
Label class, AWT, 853, 881
Lambda expression(s), 18, 391–408, 418–419, 600
as arguments, passing, 401–403
block, 392, 397–399
body, 392, 397, 398
and comparators, 620–621, 624
definition of, 391
and exceptions, 394, 404–405
and generics, 399
to handle action events, 886–887, 1073–1074, 1090, 1111
parameters, 392–393, 394, 395–397, 405
and the stream API, 1005
target type, 392, 393, 394, 399, 401, 403, 405
and var, 19
and variable capture, 405–406
Lambda arrow operator (–>), 18, 67, 85, 392
last( ), 580, 912
lastElement( ), 638, 639
lastIndexOf( ), 494, 495–496, 508, 509, 577, 578, 638, 639
lastKey( ), 609
Late binding, 194
Layered pane, 1065, 1066
Layout managers, AWT, 855, 879, 882, 904–919
default, 905
LayoutManager interface, 905
Lazy behavior (stream API stream), 1008
length instance variable of arrays, 155–157
length( ), 161, 486, 503, 565, 656
Lexer (lexical analyzer), 653
Libraries, class, 27, 38, 476
Lindholm, Tim, 6
LineNumberInputStream deprecated class, 714
LineNumberReader class, 318
lines( ), 502, 749, 770, 1009
LinkedBlockingDeque class, 983
LinkedBlockingQueue class, 983
LinkedHashMap class, 612, 615–616
LinkedHashSet class, 585, 591–592
LinkedList class, 585, 589–590
example program using the, 603–604
from a stream API stream, obtaining a, 1025
LinkedTransferQueue class, 983
LinkOption.NOFOLLOW_LINKS, 784
List
controls, 880, 894–897
event source, as an, 823, 827, 832, 895
pop-up, 891
List class ([Link]), 853, 894, 895
List interface ([Link]), 574, 577–579, 585, 589, 590, 597, 598, 631, 637, 638
from a stream API stream, obtaining an instance of the, 1022–1024
methods, table of, 578
obtaining an unmodifiable, 1025
List, Swing, 1096–1099
list( ), 648, 770
and directories, 715, 717–719
list( ), ThreadGroup, 557
listFiles( ), 719–720
ListIterator interface, 574, 595, 597–599, 600
methods, table of, 597
listIterator( ), 578, 597
ListModel interface, 1097
ListResourceBundle class, 704–706
ListSelectionEvent class, 1097, 1098, 1105
ListSelectionListener interface, 1097, 1098
ListSelectionModel interface, 1097, 1105
Literals, 36, 45–48
class, 298
regular expression, 1033
string. See String literals
load( ), 436–437, 441–442, 533, 540, 648, 650–652
LocalDate class, 1052, 1053, 1056, 1057
LocalDateTime class, 1052, 1053, 1056, 1057
Locale class, 500, 669–670, 1048
Locale Data Markup Language (LDML), 670
[Link] class, 670
[Link], 670
LocalTime class, 1052, 1053, 1056, 1057
Lock interface, 957, 984, 985, 986
methods, table of, 984
lock( ), 957, 984, 985
Locks, 984–986
reentrant, 985, 986
Log, program, 542
log( )
math method, 549
servlet method, 1164, 1166
Logical operators
bitwise, 73–75
Boolean, 81–83
long, 39, 40, 41–42, 45
and automatic type conversion, 52
and automatic type promotion, 54
literal, 45–46
Long class, 287, 288. 511, 517, 524, 525
methods, table of commonly used, 522–524
Long-term support (LTS) release, 12
LongAccumulator class, 987
LongAdder class, 987
LongBuffer class, 765
longs( ), 672
LongStream interface, 1008, 1009
longValue( ), 288, 512, 514, 516, 518, 519, 520, 523
Look and feels, 1062–1063
lookup( ), 1045
Loop(s), 87
Boolean object to control, using a, 293
break statement and, 110–111
continue statement and, 113–114
do-while. See do-while loop
for. See for loop
infinite, 103, 110
nested, 109, 111, 112–113
with polling, event, 248, 265
while. See while loop
Low surrogate char, 529
main (default name of main thread), 252
main( ), 29–30, 117, 118, 120, 150, 153
and the Java application launcher, 29
and command-line arguments, 29, 162–163
and the source-file launch feature, 1201, 1202
and Swing programs, 1070
major( ), 536
MalformedURLException, 803
Map interface, 605–608, 609, 612, 616, 643, 644, 646
methods, table of, 606–608
map( ), 659, 660, 768, 779, 780, 783, 816
and stream API streams, 1007, 1018–1022
Map(s), 573, 604–616
classes, 612–616
collection-view of a, obtaining a, 573, 604, 605
flat, 1022
interfaces, 605–611
and stream API streams, 1018–1022
submaps of, 608–609
[Link] interface, 605, 609, 613
methods, table of non-static, 611
[Link], 779, 780
MapMode.READ_ONLY, 779, 780
MapMode.READ_WRITE, 779, 780, 783
mapMulti( ), 1022
mapMultiToDouble( ), 1022
mapMultiToInt( ), 1022
mapMultiToLong( ), 1022
MappedByteBuffer class, 765, 780
mapToDouble( ), 1007, 1021
mapToInt( ), 1007, 1021–1022
mapToLong( ), 1007, 1021
mark( ), 723, 724, 729, 733, 736, 743, 749, 765
markSupported( ), 723, 724, 733, 736, 743, 749
Matcher class, 1031, 1032–1033, 1034, 1035, 1038, 1039
matcher( ), 1032
matches( ), 502, 1032, 1036, 1039
Math class, 49, 139, 548–553
exponential functions, methods for, 549
miscellaneous methods, table of, 551–552
rounding methods, table of, 550–551
and static import example, 340–342
trigonometric functions, methods, for, 549
max( ), 412–414, 514, 516, 520, 523, 550, 1007, 1012, 1013
algorithm defined by Collections, 627, 630
MAX_EXPONENT, 513
MAX_PRIORITY, 260–261, 554
MAX_RADIX, 526
MAX_VALUE, 513, 524, 526
MediaTracker class, 853
Member, class, 23, 118
access and inheritance, 173–174
access, table of, 203
controlling access to a, 149–152, 202–206
static, 153–154
Member interface, 569, 1040
Memory
allocation using new, 56, 57, 121–122
deallocation, 133
leaks, 325, 330, 721
management, in Java, 14, 133
MemoryImageSource class, 935–937, 940
Menu bars and AWT menus, 879, 919–924
action command string of, 920
and events, 920
Menu, Choice control as a form of, 891
Menu class, AWT, 853, 919, 920, 924
Menu item as an event source, AWT, 823, 827, 832, 920
Menu(s), Swing, 1109–1141
accelerator keys, 1109, 1118, 1119–1120, 1133
action command string, 1110–1111, 1118
action to manage multiple components of a, using an, 1109, 1129–1134
and check boxes, 1121, 1122–1123
classes, interaction of core, 1110–1111
demonstration program, 1135–1141
events, 1110–1111, 1113, 1114, 1117–1118, 1121, 1122, 1124, 1125–1126
and images, 1120–1121
item as an event source, 822, 827, 832
main, creating a, 1114–1118
menu bar, 1109, 1111–1112, 1114, 1117, 1125, 1127
mnemonics, 1109, 1113, 1118, 1119–1120, 1133–1134
popup, 1109, 1110, 1123–1126
and radio buttons, 1121, 1122–1123
and submenus, 1110, 1112, 1113, 1114
and toolbars, 1109, 1110, 1127–1129
and tooltips, 1121, 1127, 1128, 1129
MenuBar class, AWT, 853, 919, 920
MenuDragMouseEvent, 1111
MenuEvent, 1111
MenuItem class, AWT, 853, 919–920
MenuKeyEvent, 1111
MenuListener, 1111
Metadata, 289, 294. See also Annotation(s)
Metal look and feel, 1063
Method class, 297, 300, 301, 569, 1040, 1042, 1152
Method reference(s), 391, 406–414
and the Collections Framework, 412–414
and generics, 411–414
to instance methods, 407–411
to static methods, 406–407
to a superclass version of a method, 411
method( ), 815
Method(s), 23, 118, 123–129
abstract. See Abstract method(s)
and annotations, 295, 314
and autoboxing/unboxing, 290–291
bridge, 384–385
calling, 125, 126
collector, 1022
default interface, 18, 19, 209, 219–223, 391, 393
dispatch, dynamic, 188–191
and the dot (.) operator, 119, 125
factory, 275–276, 797
final, 155, 194
general form, 123–124
generic, 348, 360, 366–369, 388
getter, 464, 465, 472–473, 1146–1147
hidden, using super to access, 180–181, 186
inlining, 194
interface. See Interface methods
and Java Bean introspection, 1148
and JShell, 1195–1196
lookup, dynamic, 211
native, 337
overloading, 137–142, 166–168, 187, 386–387
overriding. See Overriding, method
and parameters, 124, 127–129
passing an object to, 145–146
recursive, 147–149
reference. See Method reference(s)
resolution, dynamic, 208, 211, 212, 216
returning an object from, 146–147
returning a value from, 124, 126–127
scope defined by, 50–52
setter, 1146–1147
static, 153–154, 223–224, 340–342, 406–407
subclasser responsibility, 192
synchronized, 250, 261–263, 957, 1004
synthetic, 1192
type inference and, 368, 382–383
varargs. See Varargs
variable-arity, 163
MethodDescriptor class, 1148, 1151, 1152
MethodHandle class, 568
methodModifiers( ), 1043
MethodType class, 568
Microsoft, 8
MIME (Multipurpose Internet Mail Extensions) type, 1157, 1161
min( ), 514, 516, 520, 523, 550, 1007, 1011, 1012, 1013
algorithm defined by Collections, 627, 630
minimumLayoutSize( ), 905
minor( ), 536
MIN_EXPONENT, 513
MIN_NORMAL, 513
MIN_PRIORITY, 260–261, 554
MIN_RADIX, 526
MIN_VALUE, 513, 524, 526
mismatch( ), 635
mkdir( ), 720
mkdirs( ), 720
Model-Delegate component architecture, 1064
Model-View-Controller (MVC) component architecture, 1063–1064
Modifier class, 1040, 1042, 1043
“is” methods, table of, 1042
Module class, 561–562
module, context-sensitive keyword, 37, 38, 422
module statement, 422, 428, 445
Module(s), 18–19, 37, 421–448
and access control, 150, 421, 422, 428, 430–431, 445
automatic, 448
compiling and running code based on, 426–427
creating code based on, 422–426
declaration, 421–422
definition of the term, 421
description, 422
graph, 444–445
Java API library packages and, 18, 421, 429
layers, 448
and legacy code, 429–430
and multi-module compilation mode, 431, 435
naming conventions, 423
open, 445
and packages, 201
path, 201, 426, 427, 430, 446
platform, 429, 447
and services and service providers, example application demonstrating,
437–444
unnamed, 429
[Link] file, 422, 426, 427, 428
ModuleDescriptor class, 562, 569
ModuleFinder interface, 569
ModuleLayer class, 562
[Link] class, 562
ModuleReader interface, 569
ModuleReference class, 569
Modulus operator (%), 67, 69
Monitor, 250, 261, 264, 265, 271
Mouse events, handling, 837–840
MouseAdapter class, 844, 845, 849, 1124, 1125–1126, 1153
mouseClicked( ), 835, 844, 1124
mouseDragged( ), 835, 844, 934
mouseEntered( ), 835, 1124
MouseEvent class, 823, 825, 826, 829–830, 1124
mouseExited( ), 835, 1124
MouseListener interface, 833, 835, 837–840, 845, 846, 1124, 1125–1126
MouseMotionAdapter class, 844, 845
MouseMotionListener interface, 821, 833, 835, 837–840, 844, 845, 846
mouseMoved( ), 835, 844, 934
mousePressed( ), 835, 847, 1124, 1126, 1153
mouseReleased( ), 835, 1124, 1126
MouseWheelEvent class, 823, 830–831
MouseWheelListener interface, 833, 835, 837, 845, 846
mouseWheelMoved( ), 835
Multicore systems, 17–18, 248, 276, 391, 955, 956, 988, 992, 995, 1015
Multitasking, 247
preemptive, 249
process-based versus thread-based, 247
Multithreaded programming, 8, 14, 247–276, 553
and context switching. See Context switching
effectively using, 276
and multicore versus single-core systems, 248
and spurious wakeup, 266
and StringBuilder class, 509
and synchronization. See Synchronization
and threads. See Thread(s)
versus the concurrency utilities, traditional, 955, 1004
and parallel programming, 988
versus single-threaded system, 248
MutableComboBoxModel, 1100
MutableTreeNode interface, 1102
MVC (Model-View-Controller) component architecture, 1063–1064
Namespace collisions
between instance variables and local variables, 133
packages and, 199, 207, 342
and static import, 342
Naming class, 1044, 1045
NaN, 513, 516
nanoTime( ), 540, 541, 996
@Native built-in annotation, 305
native modifier, 337
Natural ordering, 566, 616
naturalOrder( ), 617
Naughton, Patrick, 6
NavigableMap interface, 605, 609, 614
methods, table of, 610–611
NavigableSet interface, 574, 581–582, 592, 593
methods, table of, 581
Negative numbers in Java, representation of, 72–73
NEGATIVE_INFINITY, 513
NegativeArraySizeException, 240, 632
Nest, 548
host, 548
.NET Framework, 8
NetBeans, 1158
Networking, 795–818
basics, 795–796
bidirectional communication and, 813, 818
classes and interfaces, list of, 796–797
new, 56, 57, 121–122, 129, 131, 133, 147, 192, 236, 237, 465
constructor reference and, 414, 418
and enumerations, 278, 281
and type inference, 382
NEW, 274
New I/O. See NIO
newBuilder( ), 814, 815
newByteChannel( ), 767, 771, 776, 778, 779, 780, 781, 783
newCachedThreadPool( ), 977
newCondition( ), 984, 985
newDirectoryStream( ), 771, 789, 790–792
newFileSystem( ), 775
newFixedThreadPool( ), 977–978
newHttpClient( ), 814
newInputStream( ), 772, 785–786
Newline, inserting a, 683
newOutputStream( ), 772, 785, 786–787
newScheduledThreadPool( ), 977, 978
next( ), 596, 597, 600, 694, 912, 1026, 1027
nextBoolean( ), 670, 671, 694
nextBytes( ), 670, 671
nextDouble( ), 218, 670, 671, 694, 696, 699
nextElement( ), 637, 654, 737
nextFloat( ), 670, 671, 694
nextGaussian( ), 670–672
nextInt( ), 670, 671, 694, 699
nextLong( ), 670, 671, 694
nextToken( ), 654
nextX( ) Scanner methods, 692, 694–695, 696, 699
table of, 694
NIO, 713, 763–794
buffers, 764–767
channels, 764, 767–768
charsets, 768
and directories, 789–794
packages, list of, 763
for path and file system operations, using, 787–794
selectors, 768
and the stream API, 770
for stream-based I/O, using, 775, 785–787
NIO and channel-based I/O
copying a file using, 784
reading a file using, 776–780
writing to a file using, 780–783
NIO.2, 17, 763, 775, 787
non-sealed, context-sensitive keyword, 20, 37, 38, 477, 479
noneMatch( ), 1030
NORM_PRIORITY, 261, 554
NoSuchElementException, 580, 582, 584, 608, 637, 659, 695, 701
NoSuchMethodException, 241, 297
NOT operator
bitwise unary (~), 72, 73, 74–75
Boolean logical unary (!), 81, 82
NotDirectoryException, 789
notepad, 534, 538
notify( ), 197, 265–266, 268–269, 272–274, 543, 955, 985, 1004
notifyAll( ), 197, 265–266, 543
NotSerializableException, 759
now( ), 1052–1053
null, 38, 131
alternative to using, 658
Null statement, 96
NullPointerException, 237, 240, 575, 577, 580, 582, 584, 595, 605, 608, 609,
632, 644, 702, 737
using Optional to prevent a, 658, 660
nullsFirst( ), 617–618
nullsLast( ), 617–618
Number class, 288, 357, 511, 512
NumberFormatException, 240, 288
Numbers
formatting, 679–680, 683–689
pseudorandom, 670
Oak, 6
Object class, 196–197, 265, 348, 350, 384, 542–544
as a data type, problems with using the, 352–354
Object class methods
and functional interfaces, 392
table of, 195, 543
Object reference variables
and abstract classes, 192–193, 194
and argument passing, 144, 145–146
assigning, 122–123
and cloning, 543
declaring, 121
and dynamic method dispatch, 188–191
to superclass reference variable, assigning subclass, 176, 180, 188
Object-oriented programming (OOP), 5, 6, 21–27, 117
model in Java, 13
Object(s), 23, 117, 122
creating/declaring, 119, 121–122
exact copy (clone) of, 542–543
initialization with a constructor, 129–132
to a method, passing, 145–146
monitor, implicit, 250, 264
as parameters, 142–144
returning, 146–147
serialization of. See Serialization
type at run time, determining, 334–336
[Link]( ). See notify( )
[Link]( ). See wait( )
ObjectInput interface, 757
methods defined by, table of, 757
ObjectInputFilter, 758
[Link], 758, 761
[Link], 758
[Link], 758
ObjectInputStream class, 317, 757–758
methods defined by, table of, 758
ObjectOutput interface, 755–756
methods defined by, table of, 755
ObjectOutputStream class, 317, 756–757
methods defined by, table of, 756
Objects class, 706
Observable class, 653
Observer interface, 653
Octals, 45
as character values, 47
and string literals, 48
of( ), 577, 578, 579–580, 595, 596, 605, 607, 608, 659, 660, 769, 770, 773, 776,
778–779, 983, 1030
offer( ), 582, 594
offerFirst( ), 583, 584, 589
offerLast( ), 583, 584, 589
ofFile( ), 816
offsetByCodePoints( ), 502, 508
ofInputStream( ), 816, 817
ofLines( ), 818
ofLocalizedDate( ), 1053, 1054
ofLocalizedDateTime( ), 1053
ofLocalizedTime( ), 1053
ofNullable( ), 659, 660
ofPattern( ), 1054–1056
pattern letters, 1055
ofString( ), 816, 818
onAdvance( ), 973–974, 976
open
context-sensitive keyword, 37, 38, 422
modifier, 445
open( ), 768
openConnection( ), 804, 805–806
OpenOption interface, 772
opens
context-sensitive keyword, 37, 38, 422
statement, 445
Operator(s)
arithmetic, 67–72
assignment. See Assignment operator(s)
bitwise, 72–80
Boolean logical, 81–83
conditional-and, 83
conditional-or, 83
diamond (<>), 382–383
parentheses and, 45, 85–86
precedence, table of, 85
relational, 32, 44, 45, 80–81
ternary if-then-else (?:), 82, 84
Optional class, 658–660, 1011, 1012, 1013
methods, table of, 658–659
optional( ), 536
OptionalDouble class, 658, 660
OptionalInt class, 658, 660
OptionalLong class, 658, 660
OR operator
bitwise (|), 72, 73, 74–75
bitwise exclusive (^), 72, 73, 74–75
Boolean logical (|), 81, 82
Boolean logical exclusive (^), 81, 82
OR operator, short-circuit (||) Boolean logical, 81, 83
or( ), 659, 660
Oracle, 17
Ordinal value, enumeration constant’s, 283, 284
ordinal( ), 283, 284–285, 564
orElse( ), 659, 660
orElseThrow( ), 659, 1011
out output stream, 30, 38, 318, 319, 322, 323–324, 535, 538. See also
[Link]
out( ), 677, 679
OutputStream class, 316, 317, 323, 722, 723, 726, 732, 734, 738, 740, 752,
756, 762, 785, 1166
methods, table of, 725
OutputStreamWriter class, 318
outputWriter( ), 531, 535
Overloading methods, 137–142, 166–168, 187, 386–387
@Override, built-in annotation, 305, 307
Overriding, method, 185–191
and abstract classes, 191–194
and bridge methods, 384–385
and dynamic method dispatch, 188–191
final to prevent, using, 194
in a generic class, 380–381
and run-time polymorphism, 188, 189, 191
Package(s), 150, 199–208, 225
access to classes contained in, 202–206, 207
built-in standard Java classes and, 206, 207
the default, 200, 206
defining, 200
finding, 200–201
importing, 206–208
and JShell, 1198–1199
and modules, 201
Swing, 1066
Package class, 301, 560–561
methods, table of, 560–561
package statement, 200, 206
Paint mode, setting the, 868–869
paint( ), 837, 840, 857, 858, 860, 934, 1074–1075, 1154
lightweight AWT components and overriding, 928
Paintable area, computing, 1075–1076
paintBorder( ), 1074–1075
paintChildren( ), 1074–1075
paintComponent( ), 1074–1075, 1078
Painting in Swing, 1074–1078
Panel class, 853, 854, 855, 911
Panes, Swing container, 1065–1066. See also Content pane
Parallel processing, 18, 391, 600, 602
of a stream API stream, 1005, 1008, 1009, 1015–1017, 1024, 1027, 1029
Parallel programming. See Programming, parallel
parallel( ), 1006, 1015–1016
parallelPrefix( ), 634
parallelSetAll( ), 634
parallelSort( ), 633–634
parallelStream( ), 575, 577, 1009, 1015, 1016
Parameter(s), 29, 124, 127–129
and constructors, 131–132
final, 155
and lambda expressions, 392–393, 394, 395–397, 405
names and instance variable names, 133
objects as, 142–144
and overloaded constructors, 140–141
and overloaded methods, 137, 187
and the scope of a method, 50
servlet, reading, 1166–1168
type. See Type parameter(s)
variable-length (varargs), 165, 579
Parameterized types, 348, 350
parameterModifiers( ), 1043
parse( ), 536, 1056
parseByte( ), 518, 524
parseDouble( ), 516
parseFloat( ), 514
parseInt( ), 521, 524–525
parseLong( ), 523, 524
parseShort( ), 519, 524
Parsing, definition of, 653
Pascal, 4
Passwords, reading, 754
patch( ), 535–536
Path interface, 715, 717, 769–770, 776, 787, 789–790, 793
converting a File object into an instance of the, 717, 769, 787
instance for stream-based I/O, using a, 785–787
methods, table of a sampling of, 769–790
obtaining an instance of the, 772–773, 775–776, 778, 779, 780, 781, 782–783
[Link]( ), 773, 776, 778
Paths class, 772, 773, 776
[Link]( ), 772–773, 775–776
Pattern class, 1031, 1032, 1035, 1038, 1039
Pattern matching
and instanceof, 20, 473–476
and regular expressions, 1031–1039
and switch, 480
PatternSyntaxException, 1033
Payne, Jonathan, 6
peek( ), 582, 641, 642
peekFirst( ), 583, 589
peekLast( ), 583, 589
Peers, native, 928, 1061–1062
Period class, 1057
permits
clause, 477, 478, 479
context-sensitive keyword, 37, 38, 477
Persistence (Java Beans), 1149
Phaser class, 956, 958, 970–977
compatability with fork/join, 1004
PI (Math constant), 548
PIPE, 538
Pipeline for actions on stream API streams, 18, 391, 1008, 1020–1021
PipedInputStream class, 317
PipedOutputStream class, 317
PipedReader class, 318
PipedWriter class, 318
PixelGrabber class, 937–940
Pluggable look and feel (PLAF), 1062–1063, 1064
Plug-in and pluggable application architecture, 436, 438
PNG file format, 930
Point class, 829, 830, 853
poll( ), 582, 594
pollFirst( ), 581, 583, 589
Polling, 248, 265
pollLast( ), 581, 583, 589
Polygon class, 853, 862
Polymorphism, 5, 22, 25–27, 195
and dynamic method dispatch, 188–191, 192
and interfaces, 208, 211, 216
and overloaded methods, 137, 139, 140
pop( ), 583, 584, 641, 642
Popup trigger, 1124, 1126
PopupMenu class, 853, 924
PopupMenuEvent, 1111
Port, 795, 796, 803
Portable Operating System Interface (POSIX), 774
Portability problem, 6–7, 8, 9–10, 12, 14, 20
and data types, 40
and thread context switching, 249
POSITIVE_INFINITY, 513
PosixFileAttributes class, 773, 774, 789
PosixFileAttributeView interface, 775
Possessive behavior (regular expression pattern matching), 1037
postVisitDirectory( ), 793
pow( ), 340–342, 549
pre( ), 536
Predicate<T> predefined functional interface, 419, 710, 1012
preferredLayoutSize( ), 905
previous( ), 597, 912
preVisitDirectory( ), 793
PrimitiveIterator interface, 573, 1026
[Link] interface, 573, 1026
[Link] interface, 1026
[Link] interface, 1026
print( ), 31, 38, 323, 488, 738, 752, 1166
printf( )
function, C/C++, 676, 738
method, Java, 163, 691, 738–740, 752, 753
println( ), 30, 31, 38, 197, 323, 488–489, 679, 738, 752, 1166
and Boolean output, 45
and String objects, 65
PrintStream class, 317, 319, 323, 691, 737–740
PrintWriter class, 318, 323–324, 691, 751–752, 1161
PriorityBlockingQueue class, 983
PriorityQueue class, 585, 593–594
private access modifier, 29, 150–152, 202–203
and inheritance, 173–174
Process class, 529–530, 534, 536
methods, table of some, 532
Process, definition of, 247, 529
Process-based versus thread-based multitasking, 247
ProcessBuilder class, 529, 536–538
methods, table of, 537–538
[Link] class, 536, 538
[Link] enumeration, 538
ProcessHandle class, 530–531
[Link], 530–531
Program log, 542
Programming
multithreaded. See Multithreaded programming
object-oriented. See Object-oriented programming
process-oriented, 21, 22, 26
structured, 4, 5
Programming, parallel, 17–18, 249, 600, 956, 957, 988, 1015
and the level of parallelism, 991
and specifying the level of parallelism, 991, 995–998, 1004
Project Coin, 17
Properties class, 572, 636, 647–652
methods, table of, 648
Properties, environment, 542
Property, Java Bean, 1146, 1154
boolean, 1147
bound and constrained, 1149, 1152
design patterns for, 1146–1147, 1149
PropertyChangeEvent, 1149
PropertyChangeListener interface, 1149, 1150
PropertyDescriptor class, 1148, 1151, 1152, 1154
PropertyPermission class, 706
PropertyResourceBundle class, 704
PropertyVetoException, 1149
protected access modifier, 150, 202–203
Protocols, overview of networking, 795–796
provides
context-sensitive keyword, 37, 38, 422
statement, 437, 576
Pseudorandom numbers, 670
public access modifier, 29, 150–152, 202–203
Push buttons, AWT, 880, 883–887
action command string of, 883, 885, 886, 1083–1094
Push buttons, Swing, 1071–1074, 1083–1085
action command string of, 1083–1084
push( ), 584, 641, 642
Pushback, 734–736
PushbackInputStream, 317, 732, 734–736
PushbackReader class, 318, 750–751
put( ), 605, 607, 612, 614, 616, 643, 644, 645
and buffers, 765, 766, 767, 782
putAll( ), 607, 616
PutField inner class, 756–757
putValue( ), 1130–1131, 1132
Query string, 1174
Queue, double-ended, 583–584
Queue interface, 574, 582, 583, 589, 593, 594
methods, table of, 582
quietlyInvoke( ), 1003
quietlyJoin( ), 1003
Race condition, 263
Radio buttons, 889
Swing, 1089–1091
and Swing menus, 1122–1123
Radix, 517
radix( ), 701
Random class, 218, 670–672
methods, table of core, 671
RandomAccess interface, 574, 604
RandomAccessFile class, 742, 767
RandomGenerator interface, 670
range( ), 595, 596
Raw types, 372–374
READ, 538
read( ), 99, 317, 318, 320–321, 325–326, 567, 724, 733, 735, 743, 750, 757,
758, 768, 777, 778, 785, 930–931
Readable interface, 567, 691, 697, 743
ReadableByteChannel interface, 691
readAttributes( ), 772, 774, 787–789
readBoolean( ), 741, 758
readDouble( ), 741, 758
Reader class, 317–318, 319, 320, 722, 723, 742–743, 744, 746, 755
methods defined by, table of, 743
reader( ), 320
readExternal( ), 755
readInt( ), 741, 758
readLine( ), 321–322, 524, 753, 1166
readObject( ), 757, 758, 759
readPassword( ), 753
readString( ), 770
ReadWriteLock interface, 986
Real numbers, 42
rebind( ), 1044–1045
receive( ), 810
Record class, 565
Record constructors, 465, 466–471
canonical, 465, 466–469
non-canonical, 466, 469–470
record, context-sensitive keyword, 20, 37, 38, 464
Record(s), 20, 37, 449, 457, 464–473, 548, 565
component list, 464
getter methods, 464, 465, 472–473
immutability of, 465, 470, 472
rules for, 466
Recursion, 147–149
and the Fork/Join Framework divide-and-conquer strategy, 992
RecursiveAction class, 957, 988, 990, 992, 993, 994, 998
RecursiveTask class, 957, 988, 990, 992
example program using, 998–1001
Redirect class, 536, 538
reduce( ), 1008, 1013–1015, 1016–1017, 1018–1019
Reduction operations, 1013–1015
mutable, 1025
ReentrantLock, 985
ReentrantReadWriteLock, 986
Reflection, 296, 445, 569, 1031, 1040–1043
and annotations, 296–301
and nests, 548
regionMatches( ), 491–492
register( ), 970
Regular expressions, 502, 653, 691, 699, 711, 1031–1039
definition of the term, 1031
syntax, 1033
wildcards and quantifiers, 1031, 1033, 1035–1037
reinitialize( ), 1002
Relational operators, 32, 44, 45, 80–81
Relative index, 689–690
Release cadence, 12, 535
release( ), 958–961
Reluctant behavior (regular expression pattern matching), 1036–1037
Remote interface, 1044
Remote method invocation (RMI), 15, 754, 1031, 1044–1047
RemoteException, 1044
remove( ), 575, 576, 578, 582, 590, 595, 596, 597, 607, 643, 644, 645, 880,
1070, 1111, 1113
removeActionListener( ), 1073
removeAll( ), 575, 576, 880
removeAttribute( ), 1171, 1178
removeEldestEntry( ), 616
removeElement( ), 638, 639
removeElementAt( ), 638, 639
removeFirst( ), 584, 589
removeIf( ), 575, 576
removeKeyListener( ), 821
removeLast( ), 584, 589
removeTListener( ), 1148
removeTypeListener( ), 821
renameTo( ), 716
repaint( ), 837, 840, 845, 846, 847, 858–859, 1075, 1154
@Repeatable annotation, 305, 312, 313
REPL (read-evaluate-print loop) execution, 1191
replace( ), 447, 507, 607
replaceAll( ), 502, 577, 578, 607, 1033, 1038
replaceRange( ), 903
ReplicateScaleFilter class, 940
requires, context-sensitive keyword, 37, 38, 422
requires statement, 422, 428, 429
using static with a, 445, 446
using transitive with a, 432–436
reset( ), 701, 723, 724, 729, 731, 733–734, 736, 743, 749, 765
resolve( ), 769, 770
Resource bundles, 701–706
ResourceBundle class, 701–704
methods, table of, 702–704
and modules, 704
[Link] class, 702
resume( ), 15, 272, 554
retainAll( ), 575, 576
@Retention built-in annotation, 296, 305
RetentionPolicy enumeration, 296, 568
return statement, 115, 124
in a lambda expression, 398
reverse( )
algorithm defined by Collections, 627
StringBuffer method, 506
reversed( ), 617, 620
reverseOrder( )
collection algorithm, 627, 629–630
Comparator method, 617
rewind( ), 765, 778, 781, 782
RGB (red-green-blue) color model, 865
default, 935
RGBImageFilter class, 940, 942–943
example program demonstrating the, 943–954
RGBtoHSB( ), 866
Richards, Martin, 4
Ritchie, Dennis, 4, 5
rmi protocol, 1045
RMI (Remote Method Invocation), 15, 754, 1031, 1044–1047, 1158
rmic compiler, 1046
rmiregistry (RMI registry), 1046, 1047
Run-time
system, Java,10. See also Java Virtual Machine (JVM)
type information, 15, 334, 378–380, 547
run( ), 250, 253, 254, 392, 553, 555, 673, 1002, 1070
overriding, 255, 256, 673
using a flag variable with, 272–274
RUNNABLE, 274
Runnable interface, 250, 252, 392, 553–554, 672, 673, 955, 1001, 1002, 1070
implementing the, 253–254, 256
Runtime class, 529, 532–535, 998
executing other programs and the, 534–535
methods, table of some, 533
RUNTIME retention policy, 295–296, 297, 300
[Link]( ), 529, 533, 534–535, 536
[Link] class, 535–536
[Link]( ), 533, 535
RuntimeException class, 228, 229, 237, 240, 244
RuntimePermission class, 562
@SafeVarargs built-in annotation, 305, 307
SAM (Single Abstract Method) type, 392
Sandbox, 10
save( ), 647
Scanner, 653
Scanner class, 691–701
closing an instance of the, 697
constructors, 691, 692
delimiters, 691, 699–700
demonstration programs, 695–699
hasNextX( ) methods, table of, 693
how to use, 691–692, 694–695
methods, miscellaneous, 700–701
nextX( ) methods, table of, 694
schedule( ), 673, 674
ScheduledExecutorService interface, 977
ScheduledThreadPoolExecutor class, 957, 977
Scientific notation, 46, 679–680
Scopes in Java, 49–52
nested, 50–51, 158
Scroll bars, 880, 897–900, 1094, 1095
as an event source, 824, 832, 898
Scroll pane, 1094–1096
Scrollbar class, 853, 897
ScrollPane class, 853
sealed, context-sensitive keyword, 20, 37, 38, 477, 478
search( ), 641, 642
Security manager, 324, 540, 721, 738
Security problem, 8, 9, 10, 12, 20, 754, 761
security( ), 536
SecurityException, 240, 324, 532, 540, 721, 738, 789, 792
SecurityManager class, 562
seek( ), 742
SeekableByteChannel interface, 767, 776, 779, 781
select( ), 892, 895, 900–901, 903
Selection statements, 87–95
Selectors, 768
Semaphore, 955, 956, 958–963, 1004
and setting initial synchronization state, 963
Semaphore class, 956, 958
send( ), 810, 813, 814, 815, 817, 818
Separable Model architecture, 1064
Separators, 37
SequenceInputStream class, 317, 736–737
sequential( ), 1006, 1017
Serializable interface, 755, 759, 1003, 1149
Serialization, 754–761, 762
and deserialization filters, 760–761
example program, 759–761
and Java Beans, 1149
and security, 754
and static variables, 755
and transient variables, 755, 759
serialPersistentFields array, 755
serialVersionUID constant, 760
Server process, 795
ServerSocket class, 767, 799, 809
service( ), 1158, 1161, 1163, 1167, 1173
ServiceLoader class, 436, 666
Services and service providers, 436–444
definition of the terms, 436
module-based example application demonstrating, 437–444
and modules, 437
Servlet interface, 1162, 1163, 1166
methods, table of, 1163
Servlet(s), 12, 1157–1179
advantages of, 1158
API, 1162
development options, 1158–1160
example program for a simple, 1160–1162
life cycle of, 1158
parameters, reading, 1166–1168
and portability, 12
and session tracking, 1178–1179
using Tomcat to develop, 1158, 1159–1162
ServletConfig interface, 1162, 1164, 1166
ServletContext interface, 1162, 1164
methods, table of various, 1164
ServletException class, 1163, 1166
ServletInputStream class, 1163, 1166
ServletOutputStream class, 1163, 1166
ServletRequest interface, 1161, 1162, 1164, 1166
methods, table of various, 1165
ServletResponse interface, 1161, 1162, 1164
methods, table of various, 1165
Session tracking, HTTP, 1178, 1179
Set interface, 574, 579–580, 590, 595, 605, 609
from a stream API stream, obtaining an instance of the, 1022–1024
Set-view, obtaining, 613, 646
set( ), 577, 578, 590, 597, 656, 663, 987
setAccelerator( ), 1119
setActionCommand( ), 886, 920, 1083–1084, 1090
setAlignment( ), 881
setAll( ), 634
setAttribute( ), 1164, 1171, 1178
setBackground( ), 857, 865
setBlockIncrement( ), 898
setBorder( ), 1078
setBounds( ), 855, 905
setCharAt( ), 504–505
setColor( ), 866
setConstraints( ), 914
setContentType( ), 1161, 1165
setDefault( ), 668, 669
setDefaultCloseOperation( ), 1068–1069
setDisabledIcon( ), 1083, 1121
setDisplayedMnemonicIndex( ), 1118
setEchoChar( ), 901
setEditable( ), 901, 903
setEnabled( ), 919, 1113, 1131
setFont( ), 872
setForeground( ), 857, 865
setForkJoinTaskTag( ), 1003
setHorizontalTextPosition( ), 1121
setIcon( ), 1080, 1120–1121
setJMenuBar( ), 1112, 1114
setLabel( ), 883, 887, 919–920
setLastModified( ), 717
setLayout( ), 882, 905, 1070
setLength( ), 504, 742
setLocation( ), 855
setMaxAge( ), 1172, 1178
setMnemonic( ), 1118
setN( ) setter method design pattern, 1146, 1147
setName( ), 251, 252, 555
setObjectInputFiller( ), 758
setPaintMode( ), 868
setPreferredSize( ), 855, 898
setPressedIcon( ), 1083
setPriority( ), 260–261, 555
setReadOnly( ), 717
setRolloverIcon( ), 1083
setSelectedCheckbox( ), 890
setSelectedIcon( ), 1083
setSelectionMode( ), 1097
setSerialFilter( ), 761
setSize( ), 639, 855, 856, 860, 1068
setState( ), 887, 920
setText( ), 881, 900, 903, 1080, 1083
setTitle( ), 856
setToolTipText( ), 1121
setUnitIncrement( ), 898
setValue( ), 611, 897–898, 1172
setValues( ), 897
setVisible( ), 856, 859, 860, 1070
setXORMode( ), 868–869
Sheridan, Mike, 6
Shift operators, bitwise, 72, 75–79
Short class, 287, 288, 511, 517, 524, 525
methods, table of commonly used, 519
short data type, 39, 40, 41, 45
and automatic type conversion, 52
and automatic type promotion, 54, 75
ShortBuffer class, 765
shortValue( ), 288, 512, 514, 516, 518, 519, 521, 523
show( ), 912, 1124, 1125, 1126
shuffle( ) algorithm defined by Collections, 627, 628, 630
shutdown( ), 977, 979, 992, 1003–1004
shutdownNow( ), 1003–1004
Sign extension, 75, 77–79
signal( ), 985
SimpleBeanInfo class, 1149, 1154, 1155
SimpleDateFormat class, 670, 1049–1051, 1055
formatting string symbols, table of, 1050
SimpleFileVisitor class, 793, 794
SimpleTimeZone class, 668–669
sin( ), 42, 549
SingleSelectionModel, 1092
SIZE, 513, 524
size( ), 575, 576, 590, 608, 639, 643, 644, 645, 656, 772, 774, 780
skip( ), 701, 725–726, 733, 743, 757
SKIP_SIBLINGS, 793
SKIP_SUBTREE, 793
sleep( ), 250, 251–252, 257, 556, 983
slice( ), 765
Slider box, 897
Snippet
code, 1191, 1193, 1194, 1196, 1199
ID, 1194
Socket class, 767, 799–802, 809
Socket(s)
datagram, 809–810
overview, 795–796
and servlets, 1158
TCP/IP client, 799–802
TCP/IP server, 799, 809
SocketAddress class, 810
SocketChannel class, 767, 768
SocketException, 810
sort( ), 577, 578, 633
algorithm defined by Collections, 628
sorted( ), 1008, 1012
SortedMap interface, 605, 608–609
methods, table of, 609
SortedSet interface, 574, 580, 581
methods, table of, 580
Source code file, naming a, 27
Source file(s), 27–28
annotations and, 294
compiling and running a program directly from a, 28, 1201–1202
naming a, 27
SOURCE retention policy, 295–296
split( ), 502, 1038–1039
Spliterator, 567, 573, 577, 600–602
and arrays, 634
characteristics, 602
Spliterator interface, 567, 573, 574, 595, 600–602
methods declared by, table of, 601
and streamAPI streams, 1026, 1027–1029
spliterator( ), 567, 575, 577, 634, 1006
[Link] interface, 602
[Link] interface, 602
[Link] interface, 602
[Link] interface, 602
sqrt( ), 42, 49, 340–342, 549
Stack
definition of, 25, 134
frame, 563, 564
trace, 229–230, 236, 563
walking, 564
ways to implement a, 213
Stack class, 572, 585, 636, 641–643
methods, table of, 642
StackTraceElement class, 242, 563
methods, table of, 563
StackWalker class, 564
[Link] enumeration, 564
[Link] interface, 564
StampedLock interface, 986
StandardCopyOption.COPY_ATTRIBUTES, 784
StandardCopyOption.REPLACE_EXISTING, 784
StandardOpenOption enumeration, 772, 785, 786
table of values for the, 773
[Link], 773, 781, 786
[Link], 773, 783, 785
StandardOpenOption.TRUNCATE_EXISTING, 773, 786
[Link], 773, 781, 786
Standard Template Library (STL), 573
start( ), 250, 253, 254, 255, 529, 538, 556, 1032–1033, 1035
startsWith( ), 492, 770
State enumeration, 274
Statements, 30
null, 96
Statements, control, 31, 44
iteration, 87, 95–109
jump, 87, 109–115
selection, 87–95
static, 29, 153–154, 157, 340
member restrictions, 387–388
used in a requires statement, 446
Static import, 16, 340–342
statusCode( ), 815
stop( ), 15, 272, 554
store( ), 647, 648, 650–652
str( ), 295
Stream API, 18, 1005–1030
and collections, 652, 1005, 1006, 1009, 1011, 1024
interfaces, 1006–1009
and lambda expressions, 1005
and NIO, 770
Stream interface, 577, 634, 749, 770, 1007–1008, 1022, 1029, 1030
methods, table of some, 1007–1008
and primitive types, 1008, 1009
Stream, intermediate operations on a stream API, 1008
to create a pipeline of actions, 1008, 1020–1021
lazy behavior of, 1008
stateless versus stateful, 1008
Stream, stream API
and accumulator operations, 1013, 1014, 1016–1017, 1025
collection from a, obtaining a, 1022–1025
and combiner operations, 1016–1017, 1019, 1025
definition of the term, 1005–1006
iterators and a, 1026–1029
mapping a, 1018–1022
obtaining a, 1009
operations on a, terminal versus intermediate, 1008
ordered versus unordered, 1017
parallel processing of a, 1005, 1008, 1009, 1015–1017, 1024, 1027, 1029
parallel, using a, 1015–1017, 1029
reduction operations, 1013–1015
stream( ), 576, 577, 634, 656, 659, 1009, 1011, 1016, 1021
Stream(s), byte, 316–317, 319, 320, 323, 324, 723–742
buffered, 732–736
classes in [Link], table of, 317
filtered, 732
Stream(s), character, 316, 317–318, 319, 320, 324, 723, 742–752
classes in [Link], table of, 318
Stream(s), I/O
benefits, 762
buffered, 732–736, 748–751
classes, top-level, 722–723
closing, 721–722
concatenating input to, 736–737
definition of the term, 316, 743
filtered, 732, 762
flushing, 720
and NIO, 775, 785–787
predefined, 318–319
reactive, 957
variables, predefined, 318–319
versus stream API streams, 1006
strictfp, 37, 38, 336
StrictMath class, 553
String class, 29, 65, 160–162, 483, 502, 565, 691, 1032
constructors, 484–486
methods, table of some, 501–502
String literals, 47–48, 463, 486. See also Text blocks
String(s)
arrays of, 65, 162
changing case of characters in, 499–500, 526–528
comparison, 161, 490–494
concatenating, 31, 160–161, 487–488, 497, 500–501, 505
constants, 65, 160
converting data into a, 488–489, 499
creating, 160, 484–486
extracting characters from, 489–490
formatted, creating a, 677–679
formatting a, 679, 685
immutability of, 160, 483, 496, 502
joining, 500–501
length of a, obtaining the, 161, 486
modifiable, creating and working with, 502–509
modifying, 496–498
numbers to and from, converting, 524–526
as objects, 48, 65, 160, 483
parsing a formatted input, 653–655
reading, 321–322
searching, 494–496
StringBuffer class, 160, 483, 485, 496, 502–509, 565
methods, table of some, 508
StringBufferInputStream deprecated class, 714
StringBuilder class, 160, 483, 485, 496, 509, 565, 676, 677
and synchronization, 509
StringJoiner class, 706
StringReader class, 318
StringTokenizer class, 653–655
methods, table of, 654
stringWidth( ), 876, 877
StringWriter class, 318
strip( ), 498
stripIndent( ), 499
stripLeading( ), 498, 499
stripTrailing( ), 498, 499
Stroustrup, Bjarne, 6
Stubs (RMI), 1046
Subclass, 24, 171–174, 189
generic, 374–378
subList( ), 577, 578
subMap( ), 608, 609, 611
submit( ), 980
subSequence( ), 502, 508, 565
subSet( ), 580, 581, 593
substring( ), 496–497, 508
Sun Microsystems, 6, 15, 16, 17
super, 153, 177
and bounded wildcard arguments, 366
and interface default methods, 223
and method references, 411
and methods or instance variables, 180–181, 186
super( ) and superclass constructors, 177–180, 184, 256
Superclass, 24, 171–174, 189, 199
abstract, 191–194
generic, 374–376
Supplemental character, definition of, 528
Supplier<T> predefined functional interface, 419, 710, 1025
@SuppressWarnings built-in annotation, 305, 307
suspend( ), 15, 272, 554
Swing, 15, 315, 836–837, 879, 1061–1107
applet, 1066
application, example of a simple, 1066–1071
and the AWT, 851, 879, 1061–1062
component classes, list of, 1064–1065
components. See Components, Swing
containers. See Container(s), Swing
event handling, 1070–1074
history of, 1061–1062
menus. See Menu(s), Swing
and MVC architecture, 1063–1064
packages, list of, 1066
and painting, 1074–1078
threading issues, 1070, 1074
Swing: A Beginner’s Guide (Schildt), 1061
SwingConstants interface, 1080
SwingUtilities class, 1070
switch expression, 20, 449, 450–459
and the arrow case, 454–458
and code blocks, 456–457
and records, 457
and yield, 37, 452–454, 455, 457
switch statement, traditional, 90–95, 109, 111, 449, 450
and the arrow case, 457–458
and auto-unboxing, 292
nested, 94–95
pattern matching and the, 480
using enumeration constants to control a, 91, 278–280
using a String to control a, 16, 91, 93–94
versus the if statement, 94–95
Synchronization, 14, 249–250, 261–265
and atomic operations, 986–987
and collections, 584, 629, 636
and deadlock, 270–271
and interprocess communication, 265–270
objects, using, 958–977
race condition and, 263
and StringBuilder class, 509
and value-based classes, 345, 512
via synchronized block, 263–265, 629
via synchronized method, 250, 261–262
versus concurrency utilities, traditional, 955, 1004
synchronized modifier, 261, 955, 984, 1004
used with a method, 261–263
used with an object, 263–265
synchronizedList( ), 628, 629
synchronizedSet( ), 628, 629
Synchronizers, 955, 956–957
SynchronousQueue class, 983
System class, 30, 38, 318, 538–542
methods, table of non-deprecated, 539–540
[Link]( ), 320, 539, 752–753
[Link] standard error stream, 318, 319, 538
[Link]( ), 539, 837, 840, 857, 859, 1118
[Link]( ), 539, 542
[Link]( ), 539, 647
[Link]( ), 539, 542
[Link] standard input stream, 318, 319, 535, 538, 691, 752
[Link]( ), 99
[Link] interface, 542
[Link] class, 542
[Link]( ), 540, 541, 996
[Link] standard output stream, 30, 38, 318, 319, 322, 323, 324, 535,
538, 691, 737, 739, 752
and static import, 342
Tabbed panes, 1092–1094
Table, Swing, 1105–1107
TableColumnModel, 1105
TableModel, 1105
TableModelEvent class, 1105
tailMap( ), 608, 609, 611
tailSet( ), 580, 581
@Target built-in annotation, 305, 306, 308
TCP/IP, 14, 796
client sockets, 799–802
disadvantages of, 809
server sockets, 799, 809
See also Transmission Control Protocol (TCP)
TemporalAccessor, 681
TERMINATE, 793
TERMINATED, 274
Ternary if-then-else operator (?:), 82, 84
test( ), 419, 708, 709, 710, 1012–1013
Text
area, 831, 835, 903–904
components as an event source, 831, 832
editing controls, 880, 900–904
formatting using [Link] classes, 1031, 1047–1052
output using font metrics, managing, 875–878
Text blocks, 20, 48, 449, 459–463
and escape sequences, 459, 462–463
and whitespace, 460–462
Text fields, 831
AWT, 900–902
Swing, 1081–1083
TextArea class, AWT, 854, 903–904
TextComponent class, 854, 900, 903
TextEvent class, 823, 831, 903
TextField class, AWT, 854, 900–901
TextListener interface, 833, 835
textValueChanged( ), 835
thenComparing( ), 618, 623–624
thenComparingDouble( ), 618
thenComparingInt( ), 618
thenComparingLong( ), 618
this, 132–133, 153
and lambda expressions, 405
and type annotations, 307, 308, 311
this( ), 342–344
Thompson, Ken, 4
Thread class, 15, 250, 251, 256, 272, 274, 553–556, 672, 955, 988
constructors, 253, 256, 553–554
extending, 255–256
methods, table of non-deprecated, 554–556
Thread pool, 955, 977–979, 989, 990–992, 995, 998, 1003–1004
common, 989, 990, 991, 992, 995, 998, 1004
Thread(s)
communication among, 265–270
creating, 252–257
creating and starting a, 275–276
daemon, 673, 992, 1001
and deadlock, 270–271, 554, 1070
definition of the term, 247
executors to manage, using, 957, 977–979
group, 252, 556–560
local variables, 560
main, 250–252, 254, 256, 257, 258, 1070
messaging, 250
priorities, 249, 260–261, 554
race condition of, 263
resuming, 272–274, 557–560
return a value, that, 979–982
and spurious wakeup, 266
states of, possible, 249, 274–275
stopping, 272
suspending, 250, 252, 272–274, 557–560
and Swing, event dispatching, 1070, 1074
synchronization. See Synchronization
[Link] interface, 567
ThreadGroup class, 553, 556–560, 567
methods, table of non-deprecated, 556–557
ThreadLocal class, 560
ThreadPoolExecutor class, 957, 977
throw, 227, 236–237, 246
Throwable class, 228, 229, 232, 236, 237, 241, 244, 333, 389, 562, 563
methods defined by, table of, 242
obtaining an object of the, 236–237
throws, 227, 237–238, 240
Thumb, 897
time Calendar class instance variable, 662
Time and date
formatting, 681–682, 1031, 1047–1051, 1053–1056
[Link] classes that deal with, 660–670
strings, parsing, 1056–1057
Time and Date API, 662, 1031, 1047, 1051–1057
packages, list of, 1051
timedJoin( ), 983
timedWait( ), 983
TIMED_WAITING, 274
Timer class, 672–674
methods, table of, 674
TimerTask class, 672–674
methods, table of, 673
Timestamp, event, 823
TimeUnit enumeration, 957, 964, 980, 982–983
TimeZone class, 667–668
methods defined by, table of some, 667–668
to
context-sensitive keyword, 37, 38, 422
clause, 431, 445
to( ), 538
toAbsolutePath( ), 770, 787
toArray( ), 576, 587–588, 1008
toBinaryString( ), 521, 523, 524, 525–526
toCharArray( ), 490
toChronoUnit( ), 983
toDays( ), 983
toDegrees( ), 552–553
ToDoubleFunction functional interface, 710, 1021
toFile( ), 769
Toggle button, Swing, 1085–1087
toHexString( ), 515, 516, 521, 524, 525–526
toHours( ), 983
Tokens, 653, 691, 699
tokens( ), 701
toLanguageTag( ), 670
toList( ), 1008, 1022, 1024, 1025
toLocalDate( ), 1053
toLocalTime( ), 1053
toLowerCase( ), 499–500, 527, 529
Tomcat, 1158, 1159–1162
toMicros( ), 983
toMillis( ), 983
toMinutes( ), 983
toNanos( ), 983
toOctalString( ), 521, 524, 525–526
Toolbars, 1109, 1110, 1127–1129
undocked, 1127
Tooltips, 1121, 1127, 1128, 1129
TooManyListenersException, 1148
toPath( ), 717, 769, 787
toRadians( ), 552–553
toSeconds( ), 983
toSet( ), 1022, 1024
toString( ), 197, 232, 241, 242, 288, 295, 301, 323, 464, 466, 488, 499, 515,
516, 518, 519, 521, 524, 525, 531, 543, 547, 556, 557, 561, 562, 563, 564, 565,
587, 634, 639, 645, 656, 657, 659, 661, 675, 677, 679, 738, 752, 769, 770, 799,
822, 870, 876, 1003, 1040, 1102
advantages to overriding, 197, 488–489
totalCPUDuration( ), 531
toUpperCase( ), 499–500, 527
toZonedDateTime( ), 666
transient modifier, 333, 1149
transitive, context-sensitive keyword, 37, 48, 422, 432–436
translateEscapes( ), 499
translatePoint( ), 829
Transmission Control Protocol (TCP)
definition of, 795–796
and stream-based I/O, 796
See also TCP/IP
TreeExpansionEvent class, 1102
TreeExpansionListener interface, 1102
TreeMap class, 612, 614–615, 616, 652
example using a comparator, 621–624
TreeModel, 1102
TreeModelEvent class, 1102
TreeModelListener interface, 1102
TreeNode interface, 1102
TreePath class, 1102
Trees, Swing, 1101–1104
TreeSelectionEvent class, 1102
TreeSelectionListener interface, 1102, 1103
TreeSelectionModel, 1102
TreeSet class, 585, 591, 592–593, 616, 652
example using a comparator for sorting an instance of the, 619–621
trim( ), 467, 498
trimToSize( ), 508, 587, 639
true, 38, 44, 45, 47, 81, 82, 83
TRUE, 529
True and false in Java, 47, 81
Truncation, 53–54
try block(s), 227, 228, 230–236, 237–239, 246
nested, 234–236
try-with-resources statement, 17, 228, 245, 325, 330–333, 567, 690, 697,
720, 721–722, 728, 767, 768, 776, 789, 800, 801–802, 810, 1006
advantages to using, 330, 331, 722
and local variable type inference, 332
tryAdvance( ), 600–602, 1027
tryLock( ), 957, 984–985
trySplit( ), 1028–1029
tryUnfork( ), 1003
Two’s complement, 72–73
TYPE, 513, 524, 526, 529
Type argument(s), 350–351, 352, 356
and bounded types, 357–359
and generic class hierarchies, 374
and generic interface implementation, 372
and type inference, 368, 382–383
Type conversion
automatic, 39, 52, 138–139
narrowing, 52
widening, 52
Type enumeration, 538
Type inference, local variable, 19, 62–65
advantages of using, 63
in a for loop, 108
and generics, 383
and inheritance, 195–196
and lambda expressions, 396
with reference types, 168–170
and streamlining code, 19, 63, 168–169, 383
and the try-with-resources statement, 332
Type interface, 569
Type parameter(s)
and bounded types, 356–359, 371–372
cannot create an instance of a, 387
and class hierarchies, 375–378
and erasure, 351, 384
and primitive types, 352
and static members, 387–388
and type safety, 352
used with a class, 350, 355–357 359
used with a method, 350, 366–369
and wildcard arguments, 359–368
Type safety
and collections, 629
and generic methods, 369
and generics, 347, 348, 351, 352–354
and raw types, 372–374
and wildcard arguments, 359–362, 363
type( ), 538
Type(s), 31
aggregate, 464
annotations, 18, 307–312
bounded, 357–359
casting, 52–54
checking, 13, 17, 39, 351, 352, 373, 389
class as a data, 117, 119, 121, 122, 123, 134
inference, 368, 382–383, 393, 396, 399, 405
inference, local variable. See Type inference, local variable
intersection, 359
non-reifiable, 307
parameterized, 348, 350
promotion, 41, 54–55, 75–77
raw, 372–374
SAM (Single Abstract Method), 392
simple, 39
TypeDescriptor interface, 545
Types, primitive (simple), 39–40, 122, 144, 286, 352, 512
autoboxing/unboxing and, 289–292, 294, 588
and collections, 588
iterators for, 573
to a string representation, converting, 487, 488, 499
to or from a sequence of bytes, converting, 740–742
wrappers for, 286–289, 294, 352, 512–529
Typesafe view of a collection, obtaining a dynamically, 629
UDP protocol, 796, 809
UI delegate, 1064
ulp( ), 550, 551
UnaryOperator<T> functional interface, 419, 710
UnavailableException, 1163, 1166
Unboxing, 289
UncaughtExceptionHandler interface, 567
method uncaughtException( ), 567
Unchecked warnings and raw types, 374
UnicastRemoteObject, 1044
Unicode, 43, 44, 47, 316, 317, 485, 486, 490, 528, 742
code points, table of some Character methods providing support for, 530
support for 34-bit, 528–529
Unicode Technical Standard (UTS) 37, 670
Uniform Resource Identifier (URI), 808
Uniform Resource Locator (URL). See URL (Uniform Resource Locator)
UNIX, 5, 795
UnknownHostException, 798
unlock( ), 957, 984, 985
unmodifiable... collections methods, 628–629
unordered( ), 1006, 1017
Unreachable code, 115, 233
unread( ), 735, 750–751
UnsupportedOperationException, 222, 240, 574, 577, 595, 605, 629, 774
update( ), 535–536, 858, 859, 860
URI (Uniform Resource Identifier), 808
URI class, 808
URL (Uniform Resource Locator), 802–803, 808, 1157, 1158
query string, 1174
specification format, 802–803
URL class, 802–804, 805, 806
URLConnection class, 804–807, 808
methods, list of some, 804–805
useDelimiter( ), 699–700
User Datagram Protocol (UDP), 796, 809
useRadix( ), 701
uses
context-sensitive keyword, 37, 38, 422
statement, 437, 443, 444
UTS 37, 670
UUID class, 706
val( ), 295
value (annotation member name), 304, 305
Value-based classes, 345, 512, 658, 1052
valueChanged( ), 1097, 1098, 1102, 1103
valueOf( ), 280–281, 287, 288, 488, 499, 513, 515, 516, 517, 518, 519, 522,
524, 526, 529, 531, 564, 656
values( ), 280–281, 605, 608
van Hoff, Arthur, 6
var, context-sensitive keyword, 19, 37, 38, 63–65, 108, 169, 195, 332, 383,
396
restrictions on using, 64–65, 350
Varargs, 16, 163–168
and ambiguity, 167–168
methods, overloading, 166–167
and Java’s printf( ), 163
parameter, 165, 579
Variable(s), 48–52
capture, 405–406
declaration, 31, 33, 48–49, 50–52, 62–65
definition of the term, 30, 48
dynamic initialization of, 49
effectively final, 405–406
enumeration, 278
final, 155, 277
instance. See Instance variables
interface, 209, 216–218
interface reference, 210–212, 216
and JShell, 1192–1193
loop control, 99–102, 103
member, 23
object reference. See Object reference variables
pattern, 473–476
scope and lifetime of, 49–52
temporary, 1198
type inference, local. See Type inference, local variable
volatile, 334
Vector class, 572, 585, 604, 636, 637–641
legacy methods, table of, 638–639
Version information, obtaining, 535–536
version( ), 533, 536
VetoableChangeListener interface, 1149, 1150
Viewport, scroll pane, 1094, 1095
visitFile( ), 793, 794
void, 29, 123
Void class, 529
volatile modifier, 334
wait( ), 197, 265–266, 268–269, 272–274, 543, 955, 983, 985, 1004
waitFor( ), 532, 534
WAITING, 274
WALL_TIME, 669
walk( ), 564, 770
walkFileTree( ), 792–794
Warth, Chris, 6
Watchable interface, 769
WeakHashMap class, 612
Web. See World Wide Web
Web browser, 802, 1157, 1158, 1160, 1161
executing applet in, 8, 11
Web server and servlets, 1158
Web Start. See Java Web Start
WebSocket
class, 818
protocol, 813
weightx constraint field, 915, 916
weighty constraint field, 915, 916
while loop, 95–97
and break, 110
and continue, 113
instanceof used with the, pattern matching form of, 476
Whitespace, 36, 88
characters, 653
from a string, removing, 498–499
and text blocks, leading, 460–462
whois, 796, 800–802
Wildcard arguments, 359–366, 380
bounded, 362–366
used in creating an array, 389
Window, AWT-based
class hierarchy, 854–855
close event, 837, 840, 845, 857
as an event source, 831, 832
frame. See Frame window
and graphics, 860
paint mode, setting the, 868–869
top-level, 855
Window class, 832, 854, 855, 857, 924
Window, Swing JFrame, 1068
windowActivated( ), 836
WindowAdapter class, 844, 845
windowClosed( ), 836
windowClosing( ), 836, 840, 844, 857, 859
WindowConstants interface, 1069
windowDeactivated( ), 836
windowDeiconified( ), 836
WindowEvent class, 823, 825, 831–832
WindowFocusListener interface, 833, 835, 845
windowGainedFocus( ), 835
windowIconified( ), 836
WindowListener interface, 833, 836, 840, 844, 845, 857, 859
windowLostFocus( ), 835
windowOpened( ), 836
WindowStateListener interface, 845
with, context-sensitive keyword, 37, 38, 422, 437
Work stealing, 991, 1003
World Wide Web (WWW), 6, 7, 13, 20, 803
wrap( ), 765
Wrappers, primitive type, 286–289, 294, 352, 512–529
WRITE, 538
write( ), 317, 318, 323, 329–330, 725, 738, 744, 755, 756, 768, 781, 782, 786
writeBoolean( ), 740, 756
writeDouble( ), 740, 756
writeExternal( ), 755
writeInt( ), 740, 756
writeObject( ), 755, 756, 759
Writer class, 317–318, 722, 723, 742, 743–744, 745, 755
methods defined by, table of, 744
writeString( ), 770
writeTo( ), 732
X
XOR (exclusive OR) operator (^)
bitwise, 72, 73, 74–75
Boolean logical, 81, 82
XOR paint mode, 868–869
Yellin, Frank, 6
yield
context-sensitive keyword, 37, 38, 452
statement, 450, 452–454, 455, 457
Zero crossing, 73
ZIP file format, 711