Synopses & Reviews
Java Examples in a Nutshell is chock full of practical real-world Java programming examples. The author of the bestsellingJava in a Nutshell has created an entire book of example programs that you can learn from and modify for your own use. If you learn best "by example," this is the book for you.This book is a companion volume to Java in a Nutshell. WhileJava in a Nutshell is a quick-reference at heart, it also includes an accelerated introduction to Java programming. Java Examples in a Nutshell picks up where that book leaves off, providing a suite of example programs for novice Java programmers and experts alike. This book doesn't hold your hand or supply detailed explanations of Java syntax or method calls; it simply delivers well-commented working examples that help you explore the wide range of what is possible with Java 1.1. Each chapter concludes with programming exercises that suggest further avenues for building on what you have learned.Java Examples in a Nutshell contains all of the example programs from the first edition of Java in a Nutshell, completely updated for Java 1.1. In addition, the I/O, networking, and GUI chapters have been augmented to include even more practical examples. It also expands on the examples from the second edition of Java in a Nutshell that demonstrate the new features in Java 1.1, including the new AWT event handling model, the JavaBeans API, internationalization, object serialization, and reflection.In addition, this book provides never-before-published programming examples for remote method invocation, database connectivity, and security -- important elements of the Java Enterprise APIs. Finally, the book offers a glimpse of the features of "Swing," the set of new components that are part of the forthcoming Java Foundation Classes (JFC).
Synopsis
"Java Examples in a Nutshell is chock full of practical real-world Java programming examples that you can learn from and modify for your own use. From the author of the bestselling "Java in a Nutshell, this companionbook picks up where "Java in a Nutshell leaves off, providing a suiteof example programs for novice Java programmers and experts alike. "Java Examples in a Nutshell contains all of the example programs from thefirst edition of "Java in a Nutshell, completely updated forJava 1.1, and expands on the examples from the second edition thatdemonstrate the new features in Java 1.1. It also provides never-before- published programming examples for remote method invocation, databaseconnectivity, and security -- important elements of the Java Enterprise APIs.Finally, the book offers a glimpse of the features of "Swing," the set of newcomponents that are part of the forthcoming Java Foundation Classes (JFC).
Synopsis
From the author of "Java in a Nutshell" comes "Java Examples in a Nutshell"--chock-full of practical, real-world Java programming examples that readers can learn or modify for their own use. A must-have for anyone who prefers to learn "by example".
About the Author
Flanagan has a degree in computer science and engineering from the Massachusetts Institute of Technology. He is a consulting computer programmer, user interface designer, and trainer.
Table of Contents
Table of Contents
Preface
1. Java Basics
Hello World
FizzBuzz
The Fibonacci Series
Using Command-Line Arguments
Echo in Reverse
FizzBuzz Switched
Computing Factorials
Recursive Factorials
Caching Factorials
Computing Big Factorials
Handling Exceptions
Interactive Input
Using a StringBuffer
Sorting Numbers
Computing Primes
Exercises
2 Objects, Classes, and Interfaces
A Rectangle Class
Testing the Rect Class
A Rect Subclass
Another Subclass
Complex Numbers
Computing Pseudo-Random Numbers
Computing Statistics
A Linked List Class
Advanced Sorting
Exercises
3 Applets
Introduction to Applets
A First Applet
Drawing Graphics
Handling Events
Reading Applet Parameters
Images and Sounds
JAR Files
Signed Applets
Exercises
4 Graphics
Drawing with the Graphics Object
Fonts
Colors
Cursors
Simple Animation
Animation with Double-Buffering
Animation with Images
Image Scaling, Cropping, and Flipping
Filtering Images
Printing an Applet
Exercises
5 Events
The Java 1.0 Event Model
Scribbling in Java 1.0
Java 1.0 Event Details
The Java 1.1 Event Model
Scribbling in Java 1.1
Scribbling with External Classes
Scribbling with Inner Classes
Scribbling with Adapter Classes
Inside the Java 1.1 Event Model
Java 1.1 Event Details
Exercises
6 Graphical User Interfaces
Components
Containers
Layout Management
Frames
A Closeable Frame
Menus
Dialogs
A Dialog with User Response
Custom Components
Putting It All Together
Exercises
7 Data Transfer
An Overview of Cut-and-Paste
Simple String Cut-and-Paste
Custom Cut-and-Paste
Exercises
8 Input/Output
Files and Streams
Working with Files
Copying File Contents
Reading and Displaying Text Files
Listing Directory and File Information
Compressing Files and Directories
Filtering Character Streams
Filtering Lines of Text
A Custom HTML Output Stream
A Custom Hardcopy Stream
Exercises
9 Networking
Downloading the Contents of a URL
Using a URLConnection
Sending Email Through a URLConnection
Connecting to a Web Server
A Simple Web Server
A Proxy Server
Networking with Applets
A Generic Client
A Generic Multi-Threaded Server
A Multi-Threaded Proxy Server
Sending Datagrams
Receiving Datagrams
Exercises
10 Threads
Threads and Thread Groups
Deadlock
Pipes
Exercises
11 Java Beans
Bean Basics
A Simple Bean
A More Complex Bean
Custom Events
Specifying Bean Information
Defining a Simple Property Editor
Defining a Complex Property Editor
Defining a Bean Customizer
Naming Patterns and Conventions
Exercises
12 Reflection
Obtaining Class and Member Information
Invoking a Named Method
Exercises
13 Object Serialization
Simple Serialization
Custom Serialization
Serialization and Class Versioning
Serialized Applets
Advanced Serialization
Exercises
14 Internationalization
A Word About Locales
Unicode
Character Encodings
Handling Local Customs
Localizing User-Visible Messages
Formatted Messages
Exercises
15 Remote Method Invocation
Remote Banking
A Bank Server
A Multi-User Domain
Remote MUD Interfaces
The MUD Server
The MudPlace Class
The MudPerson Class
A MUD Client
Exercises
16 Database Access with SQL
Accessing a Database
Using Database Metadata
Building a Database
Using the API Database
Atomic Transactions
Exercises
17 Security and Cryptography
A Custom SecurityManager
Message Digests and Digital Signatures
Digitally Signed Objects
Exercises
Appendix A. JFC and Swing
Index