Page 841 - Introduction to Programming with Java: A Problem Solving Approach
P. 841
nested loops in, 133–35 purpose, 107
switch, 119–23
while loops in, 123–26
Controller class (Garage Door pro- gram), 280
Controlling expressions in switch state- ments, 120
Conversion
evaluating, 450–51
primitive types to objects, 161–64 by promotion, 74–75, 441–42
of read-in strings, 98–99
of upper- and lowercase characters,
165–66
using cast operator, 81–83, 442–43,
444
Conversion characters, 174 Coordinate systems, 544 Copying arrays, 379–82 cos method, 158, 160 count variables
basic function, 36–37
terminating loops with, 36–37, 38–39,
40–41
Countdowns, 127, 129–30, 457–58 Counter program, 517–18 CourseDriver class, 388–89, 390 CPUs (central processing units), 3–4, 8 Crashes, 89. See also Error messages; Ex-
ception handling
Declaration statements
analysis, 247
arrays, 373–75
basic syntax, 65
class constants, 353–54
class variables, 346
coding conventions for, 297, 301 preferred sequence, 354
for sequential steps, 548
Decrement operator, 79, 445–46, 765 Default constructors, 267–70, 484, 486 default reserved word, 752
Default values
array elements, 376
class variables, 348 graphical text boxes, 653 instance variables, 209–10 reference variables, 209, 247
Delays, creating with empty statements, 454–55
delete method, 627
Delimiters, 759
DeMorgan’s theorem, 140
Derived classes, 482
Descendant classes, 482
Design. See Program design
Design philosophy, 310–12
Development environments, 15–16
Dialog boxes. See also Graphical user inter-
faces (GUIs) defined, 16, 95
Index 807 as primitive type, 85
when to use, 69–70, 436–37
Double quotes, 26, 62, 166
Dow Jones Industrial Average, 383, 415 DragSmiley program, 682–85 drawImage method, 184, 185 drawLine method, 185, 584 drawPolyLine method, 584–85 drawRect method, 184, 185 drawString method, 185
Driven classes, 275–84, 326–27
Driver classes, 203–6
Drives, 7
Drop-down lists, 726–28
Dummy constructors, 270
Dummy methods, 529, 530–31
Dumps, 404
Duplicate code, avoiding, 273
Duplicate names. See also Naming rules
in overloaded methods, 262–65 using inheritance to eliminate, 491 for variables in separate blocks, 223
DVDs, 6
Dynamic allocation, 346 Dynamic binding, 509, 520, 522
E
E constant, 159
E return type, 411
Echo printing, 121
Editing text, 15–16. See also
CRC cards, 331–35 displaying, 95–99 setEditable method Apago PDF Enhancer
createContents method, 663–64 CreateNewFile program, 570–72 Cryptic code, 448
Cunningham, Ward, 331
Curly braces. See Braces Current directory, 19, 627 Custom packages, 756–58 Customer class, 499 Customer requirements, 9, 26 Cylinders, 544–50
D
-d option, 771
Data files. See Files
Data in objects, 197, 198
Data types. See also Return types
for constants, 71
converting, 81–83, 161–64
in declaration statements, 65 ignoring in pseudocode, 28
in initialization statements, 68–69 numeric, 69–70, 434–37
in overloaded methods, 262
as return values, 218–20 specifying in class diagrams, 200
DataInputStream class, 604, 619 DataOutputStream class, 604, 618–19 DayTrader program, 456–57
Dealership program, 474–79, 498–500 Dealership2 program, 491–93
Debuggers, 46, 214–15. See also Tracing Debugging with temporary print state-
ments, 225 Decimal points, 69
Deck class, 496
file-chooser example, 629–34 message dialog implementation, 667–
70
Diamonds in flowcharts, 30, 107 Directories, 16–18, 19, 627
Discrete events, 797
Discrete triangular distributions, 178,
179
Discrete uniform distributions, 176–79 Disk drives, 7
Diskettes, 7
Distribution, 140
Division
floating-point, 74–75, 82–83
in precedence of operations, 76, 77 by zero, 40–41, 273, 579
do loops
overview, 126–27
when to use, 132–33
while condition placement, 762
do reserved word, 752 Documentation
defined, 9, 325
for difficult code, 734 self-documenting code, 64
Dog class, 519
DOS operating system, 323 Dot prefixes, 263–65, 307, 350 double constants, 71
double data type
converting to strings, 162 default value, 209, 437 defined, 752
dialog input, 98
for factorials, 130
Elegant code
basic features, 118 with constructors, 272 for loops, 132, 138
Elements. See also Arrays accessing in arrays, 371–72
in array declarations, 373 ArrayList handling, 409–12 defined, 371
generic names for types, 411 initializing, 375–76
with shifting values, 382–85
Ellipses, 185
else ifconstruct,763
else reserved word, 752 Embedded assignments, 446–48 Embedded layout managers, 712–14,
729
Employee class, 484–85, 528 Employee program, 268, 269 Employee2 class, 531 Employee2 program, 269, 270 Employee3 class, 271, 541, 542 Empty statements, 220–21, 454–56 Empty strings, 89, 166–69 EmptyBorder class, 731–33 Encapsulation
basic principles, 197
of helper methods, 305–6 implementation techniques, 308–10 variable names and, 223
End comments, 760–61 End tags, 613
End user needs, 9, 26 End-of-line symbols, 616