Page 845 - Introduction to Programming with Java: A Problem Solving Approach
P. 845
Left-pointing arrow, 47
length method, 89, 377
length property, 377–79, 398, 402 Lexicographical ordering of strings, 166 License-agreement example, 719, 720, 721 Lightweight components, 680 Limited-resource devices, 15
Line breaks, 301
Line drawing, 185, 561
Line numbers, 44, 46
Line plotting, 561, 562, 584–92
Line wrapping, 719–20
lineDraw method, 561
LinePlot program, 559–61, 562 LinePlotGUI program, 584–92
Linked classes, 481–82
Linked lists, 358–64, 423
LinkedList class, 154, 364
Listeners
as anonymous objects, 660–62
for button components, 663, 664 defined, 646
to distinguish multiple events, 671, 672 implementing, 657–58
as inner classes, 658–59 JCheckBox, 723 mouse, 680–82, 683–85
Lists. See also ArrayLists; Arrays drop-down, 726–28
linked, 358–64, 423
for loops, 127–31, 457–59 nested, 41–42, 133–35
return statements in, 221–22 in sorting algorithms, 393 termination techniques, 38–41 while loops, 123–26
Lottery program, 163–64 Lowercase letters
converting to, 171–72 in variable names, 27 when to use, 766
LuckyNumber program, 558 Lunar eclipse program, 736–38
M
Machine code, 12 Main memory, 4–6 main methods
absence from applets, 188 as class methods, 351–52 in driven classes, 326–27 headings, 60–61
placing variable declarations in, 65 main reserved word, 60–61 Maintenance, 9, 221–22, 325–26 makeCopy method, 249, 250 Mammals, 479
Manager class, 477
Manager2 class, 492
Margins, creating, 731–33
markAntony.txt, 609
Index 811 description format, 298
naming, 64, 300
overloaded, 262–65
promotion in calls, 442 recursion, 784–92
relation to objects, 152, 197, 198 string, 87–90, 166–72 trigonometric, 158, 160
wrapper class, 161–62
Micro Edition applications, 15 Microprocessors, 3–4, 8
Microsoft, 8
Microsoft Windows operating system, 323 MIN_NORMAL constant, 437
MIN_VALUE constant, 437
Minimum values
named constants for, 435, 437
for random number generation, 176 Minus sign
as subtraction operator, 11, 28
as unary negation operator, 77 Misuse of empty statement, 455–56 Mixed expressions
defined, 74, 441
evaluating, 450, 451, 452 promotion in, 74–75, 441–42
mkdir method, 627 Modal components, 673 Modifiers, 72
Modules, 305–6 Modulus operator, 75
Literals, 71, 83
Local main methods, 327
Local named constants, 270, 352 Local variables
basic features, 216–17, 247 defined, 211, 216 encapsulation with, 309–10 parameters versus, 223 persistence, 218
temporary, 258, 259 using, 217–18
when to declare, 767
Logic errors, 117, 118
Logical chunks of code, separating, 66 Logical operators. See also Operators
“and” operator, 111–15
in Boolean algebra, 139–42 “not” operator, 118
“or” operator, 116–18
Logistic equation, 228 long data type
default value, 209 defined, 753
as primitive type, 85 when to use, 69, 435
Long-form tracing, 44, 45 Looping structures
algorithm forms, 36–38
assignment statements in, 447–48 braces with, 302
break statement within, 456–57, 458 choosing, 132–33
creating delays with, 454–55
do loops, 126–27
flow of control in, 30, 123
Matching catch blocks, 559 Monospaced fonts, 27, 461, 634 Apago PDF Enhancer
Math class, 155–60
MathCalculator program, 715–19 Math-calculator window, 712–14 Mathematical functions, 60–61, 155–56 Math.random method, 176–79 Maturation, modeling, 228–29 Maximum values
expression for finding, 448–49 named constants for, 435, 437
for random number generation, 176
Meaningful names, 300 Megabytes, 6
Members, 200
Memory (computer), 4–7, 252, 346 Memory leaks, 252
Menu bars, 735
Menus, 735
Mercury project, 325
Message dialogs, 96–97, 667–70 Method body, 202
Method overloading, 246 Method overriding
defined, 472
implementing, 486–88
toString methods, 515, 516, 518
Method signatures, 262 Method-call chaining, 246, 260–62 Methods
basic math, 156–58
Character class, 165–66
class versus instance types, 152, 198–99 coding conventions for, 766–67
defined, 31, 60–61
Moon missions, 325
Motherboards, 4
Mouse class, 201, 212, 347
Mouse listeners, 680–82, 683–85 Mouse2 class, 218, 219 Mouse2Driver class, 217–18 MouseDriver class, 204 MouseDriver2 class, 211 MouseListener interface, 680–81 MouseMotionListener interface,
680–81
MouseShortcut class, 328 Moving averages, 383–85 Multidimensional arrays, 402 Multiple statements on a line, 764 Multiplication
in precedence of operations, 76, 77
symbol, 28, 77
Multiplicity values, 474 Multithreading, 794–803 Mutator methods, 225–26, 304–5
N
Named constants
basic features, 72, 765
for color values, 675
for format strings, 402
hard-coded constants versus, 72, 73–74 initializing, 270
in interfaces, 534–35
levels of, 352–54
in Math class, 159–60
wrapper class, 162, 435, 437