\ IN A NUTSHELL Desktop Quick Reference Second Edition David Flanagan Technische Hochschule Darmstadt FACHBEREICH INFORMATIK BIBLIOTHEK.nventar-Mr, Secbgebiele: Standort:..K%~.. O'REILLY Cambridge Koln Paris Sebastopol Tokyo
Table of Contents Preface xi Parti: Introducing Java Chapter 1 Getting Started with Java 3 Why Is Java Interesting? 3 A Simple Example 9 Chapter 2 How Java Differs from C 14 Program Structure and Environment 14 The Name Space: Packages, Classes, and Members 16 Comments 20 No Preprocessor 20 Unicode and Character Escapes 22 Primitive Data Types 23 Reference Data Types 25 Objects 28 Arrays 29 Strings 33 Operators : 33 Statements 36 Exceptions and Exception Handling 39 Miscellaneous Differences 45
Chapter 3 Classes and Objects in Java 49 Introduction to Classes and Objects 50 Object Creation 52 Class Variables 54 Class Methods 56 Object Destruction 60 Subclasses and Inheritance 62 Overriding Methods 68 Data Hiding and Encapsulation 71 Abstract Classes and Interfaces 75 C++ Features Not Found in Java 80 Summary 81 Part II: Introducing Java 1.1 Chapter 4 What's New in Java 1.1 85 Java 1.1 Package-by-Package 86 Inner Classes 89 The New AWT Event Model 90 Deprecated Features 90 Other AWT Improvements 91 Internationalization 95 Object Serialization 97 Reflection 97 Java Beans 98 Enterprise APIs: JDBC, RMI, and Security 99 Applet Changes '. 99 New JDK Utilities 101 Chapter 5 Inner Classes and Other New Language Features 102 An Overview of Inner Classes 102 Nested Top-Level Classes and Interfaces 104 Member Classes 106 Local Classes 112 Anonymous Classes 117 Other New Features of Java 1.1 122
Part III: Programming with the Java 1.1 API Chapter 6 Applets 127 Introduction to Applets 127 A First Applet, 129 Drawing Graphics ; 130 Handling Events 131 Reading Applet Parameters 133 Images and Sounds : 134 JAR Files 138 Applet Security Restrictions 139 Signed Applets 142 Chapter 7 Events 144 The Java 1.0 Event Model 144 Scribbling in Java 1.0 149 The Java 1.1 Event Model 150 Scribbling in Java 1.1 153 Scribbling with Inner Classes 154 Inside the Java 1.1 Event Model 155 Chapter 8 New AWTFeatures 158 The ScrollPane Container 158 Popup Menus and Menu Shortcuts 159 Printing l6l Data Transfer with Cut-and-Paste 162 New Feature Demo 164 Chapter 9 Object Serialization 172 Simple Serialization 172 Custom Serialization 173 Serialization and Class Versioning 175 Serialized Applets 176 Advanced Serialization 177 Chapter 10 Java Beans 178 Bean Basics 179 A Simple Bean 180 A More Complex Bean : 184
Custom Events 188 Specifying Bean Information 189 Defining a Simple Property Editor 192 Defining a Complex Property Editor 194 Defining a Bean Customizer 196 Naming Patterns and Conventions 199 Chapter 11 Internationalization 201 A Word About Locales 201 Unicode 202 Character Encodings 207 Handling Local Customs 209 Localizing User-Visible Messages 211 Formatted Messages 216 Chapter 12 Reflection 219 Obtaining Class and Member Information 219 Invoking a Named Method 222 Part IV: Java language Reference Chapter 13 Java Syntax 227 Primitive Data Types 227 Character Escape Sequences 228 Operators 228 Modifiers 231 Reserved Words 232 Java Documentation Comment Syntax 233 Chapter 14 System Properties 235 Standard System Properties 235 Working with System Properties 236 Chapter 15 Java-Related HTML Tags 239 The <APPLET> Tag 239 The <PARAM> Tag 241 An Example HTML File 241
Chapter 16 JDK Tools 242 appletviewer The Java Applet Viewer 242 jar Java Archive Tool 246 java The Java Interpreter 247 javac The Java Compiler 251 javadoc The Java Documentation Generator 253 javah Native Method C File Generator 256 javakey Key Management and Digital Signatures 258 javap Thejava Class Disassembler 260 jdb The Java Debugger 262 native2ascii Convert Java source code to ASCII 266 serialver Class Version Number Generator 266 Part V: API Quick Reference How To Use This Quick Reference 271 Chapter 17 The Java, applet Package 275 Chapter 18 The java.awt Package 279 Chapter 19 The java. awt. datatransfer Package 335 Chapter 20 The java. awt. event Package 340 Chapter 21 The java.awt.image Package 361 Chapter 22 The java.awt.peer Package 372 Chapter 23 The java.beans Package 381 Chapter 24 The java.io Package 396 Chapter 25 The java.lang Package :. 441 Chapter 26 The java.lang.reflect Package 481 IX
Chapter 27 The java.math Package 488 Chapter 28 The java.net Package 492 Chapter 29 The java.text Package 508 Chapter 30 The java.util Package 527 Chapter 31 The java.util.zip Package 547 Chapter 32 Class, Method, and Field Index 558 Index 587