Chapter 1 Getting Started 1
1.1 THE JAVA PROGRAMMING LANGUAGE 1
1.2 DOWNLOADING THE JAVA DEVELOPMENT KIT 3
1.3 INSTALLING THE JDK 5
1.4 CREATING AND RUNNING A PROGRAM IN MICROSOFT WINDOWS 6
1.5 TROUBLESHOOTING 9
1.6 ANALYSIS OF THE HelloWorld PROGRAM 11
1.7 COMMENTS 12
1.8 PROGRAMS WITH INPUT 14
1.9 NUMERIC INPUT 16
1.10 VARIABLES AND OBJECTS 19
1.11 ARITHMETIC AND ASSIGNMENT OPERATORS 21
2.1 THE String CLASS 27
Chapter 2 Strings 27
2.2 SUBSTRINGS 28
2.3 CHANGING CASE 29
2.4 CONCATENATION 29
2.5 LOCATING A CHARACTER WITHIN A STRING 30
2.6 REPLACING CHARACTERS IN A STRING 31
2.7 REPRESENTING A PRIMITIVE VALUE IN A STRING 31
2.8 SUMMARY OF THE String CLASS METHODS 33
2.9 THE StringBuffer CLASS 34
2.10 SUMMARY OF THE StringBuffer CLASS METHODS 39
Chapter 3 Selection 43
3.1 THE if STATEMENT 43
3.2 THE if...else STATEMENT 44
3.4 NESTED CONDITIONALS 45
3.3 THE if...else if... STATEMENT COMBINATION 45
3.5 COMPOUND STATEMENTS 48
3.6 OPERATORS 48
3.7 ORDER OF EVALUATION 50
3.8 boolean VARIABLES 51
3.9 THE CONDITIONAL OPERATOR 54
3.10 ASSIGNMENT OPERATORS 55
3.11 THE switch STATEMENT 55
Chapter 4 Iteration 65
4.1 THE for STATEMENT 65
4.2 THE while STATEMENT 68
4.3 SOME NUMBER CRUNCHING 70
4.4 THE do...while STATEMENT 73
4.5 MORE NUMBER CRUNCHING 75
4.6 NESTED LOOPS 78
Chapter 5 Methods 89
5.1 SIMPLE EXAMPLES 89
5.2 LOCAL VARIABLES 90
5.3 METHODS OFTEN INVOKE OTHER METHODS 92
5.4 METHODS THAT INVOKE THEMSELVES 93
5.5 boolean METHODS 95
5.6 void METHODS 95
5.7 OVERLOADING 96
Chapter 6 Classes 110
6.1 CLASSES 110
6.2 DECLARATIONS 113
6.3 MODIFIERS 116
6.4 CONSTRUCTORS 118
6.5 COPY CONSTRUCTORS 121
6.6 DEFAULT CONSTRUCTORS 122
6.7 CLASS INVARIANTS 124
6.8 IDENTITY,EQUALITY,AND EQUIVALENCE 127
6.9 MORE CLASS INVARIANTS 129
6.10 WRAPPER CLASSES 133
Chapter 7 Composition and Inheritance 148
7.1 COMPOSITION 148
7.2 RECURSIVE CLASSES 152
7.3 INHERITANCE 157
7.4 OVERRIDING FIELDS AND METHODS 159
7.5 THE super KEYWORD 161
7.7 CLASS HIERARCHIES 163
7.6 INHERITANCE VERSUS COMPOSITION 163
7.8 THE Object CLASS 167
7.9 THE JAVA CLASS HIERARCHY 168
7.10 THE clone() AND equals() METHODS 168
Chapter 8 Arrays and Vectors 188
8.1 CHARACTER ARRAYS 188
8.2 PROPERTIES OF ARRAYS IN JAVA 191
8.3 COPYING AN ARRAY 193
8.4 THE Vector CLASS 195
8.5 THE SIZE AND CAPACITY OF A Vector OBJECT 198
8.6 CHANGES TO THE Vector CLASS IN JAVA 1.2 200
8.7 TWO-DIMENSIONAL ARRAYS 201
9.2 THE Frame CLASS 209
Chapter 9 Graphics 209
9.1 THE AWTLIBRARIES 209
9.3 THE Color CLASS 212
9.4 COMPONENTS 213
9.5 THE Button CLASS 214
9.6 MANAGING LAYOUTS 215
9.7 EVENT-DRIVEN PROGRAMMING 217
9.8 THE TextField CLASS 220
Chapter 10 Applets,Threads,and Exceptions 224
10.1 APPLETS 224
10.2 THE Applet CLASS 225
10.3 THE Thread CLASS 227
10.4 EXCEPTIONS 230
Appendix A Acronyms 234
Appendix B The JBuilder IDE 235
Appendix C The CodeWarrior IDE 238
Appendix D Computer Numbers 239
D.1 THE FINITE AND THE INFINITE 239
D.2 NUMBER TYPES 239
D.3 RANGES OF INTEGER TYPES 239
D.4 INTEGER OVERFLOW 239
D.5 RANGES OF FLOATING-POINT TYPES 241
D.6 THE INFINITY AND NaN CONSTANTS 241
Appendix E Unicode 244
Appendix F References 246
Index 248