Java: The Complete Reference

Java: The Complete Reference

by Patrick Naughton, Herbert Schildt

Paperback

$33.29 $39.95 Save 17% Current price is $33.29, Original price is $39.95. You Save 17%.

Product Details

ISBN-13: 9780078822315
Publisher: McGraw-Hill Osborne
Publication date: 12/28/1996
Pages: 886
Product dimensions: 7.44(w) x 9.08(h) x 1.77(d)

Table of Contents

Preface xxi
Acknowledgments xxiii
PART I The Java Language 3(328)
1 The Genesis of Java
3(14)
Java's Lineage
4(3)
The Birth of Modern Programming: C
4(2)
The Need for C++
6(1)
The Stage Is Set for Java
7(1)
The Creation of Java
7(2)
Why Java Is Important to the Internet
9(1)
Java Applets and Applications
9(1)
Security
10(1)
Portability
10(1)
Java's Magic: The Bytecodes
10(1)
The Java Buzzwords
11(4)
Simple
12(1)
Object-Oriented
12(1)
Robust
13(1)
Multithreaded
13(1)
Architecture-Neutral
14(1)
Interpreted and High Performance
14(1)
Distributed
14(1)
Dynamic
14(1)
Java Is Not an Enhanced HTML
15(2)
2 An Overview of Java
17(24)
Object-Oriented Programming
18(7)
Two Paradigms
18(1)
Abstraction
18(1)
The Three OOP Principles
19(6)
A First Simple Program
25(4)
Entering the Program
25(1)
Compiling the Program
26(1)
A Closer Look at the First Sample Program
27(2)
A Second Short Program
29(2)
Two Control Statements
31(4)
The if Statement
32(1)
The for Loop
33(2)
Using Blocks of Code
35(2)
Lexical Issues
37(2)
Whitespace
37(1)
Identifiers
37(1)
Literals
37(1)
Comments
38(1)
Separators
38(1)
The Java Keywords
38(1)
The Java Class Libraries
39(2)
3 Data Types, Variables, and Arrays
41(32)
Java Is a Strongly Typed Language
42(1)
The Simple Types
42(1)
Integers
43(2)
byte
44(1)
short
44(1)
int
44(1)
long
45(1)
Floating-Point Types
45(2)
float
46(1)
double
46(1)
Characters
47(1)
Booleans
48(2)
A Closer Look at Literals
50(2)
Integer Literals
50(1)
Floating-Point Literals
50(1)
Boolean Literals
51(1)
Character Literals
51(1)
String Literals
52(1)
Variables
52(5)
Declaring a Variable
52(1)
Dynamic Initialization
53(1)
The Scope and Lifetime of Variables
54(3)
Type Conversion and Casting
57(2)
Java's Automatic Conversions
57(1)
Casting Incompatible Types
57(2)
Automatic Type Promotion in Expressions
59(2)
The Type Promotion Rules
60(1)
Arrays
61(9)
One-Dimensional Arrays
61(3)
Multidimensional Arrays
64(6)
Alternative Array Declaration Syntax
70(1)
A Few Words About Strings
70(1)
A Note to C/C++ Programmers About Pointers
71(2)
4 Operators
73(26)
Arithmetic Operators
74(6)
The Basic Arithmetic Operators
74(2)
The Modulus Operator
76(1)
Arithmetic Assignment Operators
76(2)
Increment and Decrement
78(2)
The Bitwise Operators
80(10)
The Bitwise Logical Operators
82(2)
The Left Shift
84(2)
The Right Shift
86(1)
The Unsigned Right Shift
87(2)
Bitwise Operator Assignments
89(2)
Relational Operators
90(2)
Boolean Logical Operators
92(2)
Short-Circuit Logical Operators
93(1)
The Assignment Operator
94(1)
The ? Operator
95(1)
Operator Precedence
96(1)
Using Parentheses
97(2)
5 Control Statements
99(30)
Java's Selection Statements
100(9)
if
100(4)
switch
104(5)
Iteration Statements
109(10)
while
109(2)
do-while
111(3)
for
114(3)
Some for Loop Variations
117(2)
Nested Loops
119(1)
Jump Statements
119(10)
Using break
120(4)
Using continue
124(2)
return
126(3)
6 Introducing Classes
129(26)
Class Fundamentals
130(4)
The General Form of a Class
130(1)
A Simple Class
131(3)
Declaring Objects
134(3)
A Closer Look at new
135(2)
Assigning Object Reference Variables
137(2)
Introducing Methods
138(7)
Adding a Method to the Box Class
138(2)
Returning a Value
140(2)
Adding a Method that Takes Parameters
142(3)
Constructors
145(4)
Parameterized Constructors
147(2)
The this Keyword
149(2)
Instance Variable Hiding
149(1)
Garbage Collection
150(1)
The finalize() Method
150(1)
A Stack Class
151(4)
7 A Closer Look at Methods and Classes
155(32)
Overloading Methods
156(6)
Overloading Constructors
159
Using Objects as Parameters
162(3)
A Closer Look at Argument Passing
165(3)
Returning Objects
168(1)
Recursion
169(2)
Introducing Access Control
172(4)
Understanding static
176(2)
Introducing final
178(1)
Arrays Revisited
179(2)
Exploring the String Class
181(3)
Using Command-Line Arguments
184(3)
8 Inheritance
187(34)
Inheritance Basics
188(7)
Member Access and Inheritance
190(1)
A More Practical Example
191(3)
A Superclass Variable Can Reference a Subclass Object
194(1)
Using super
195(6)
Using super to Call Superclass Constructors
195(5)
A Second Use for super
200(1)
Creating a Multilevel Hierarchy
201(4)
When Constructors Are Called
205(1)
Method Overriding
206(4)
Dynamic Method Dispatch
210(4)
Why Overridden Methods?
212(1)
Applying Method Overriding
212(2)
Using Abstract Classes
214(4)
Using final with Inheritance
218(1)
Using final to Prevent Overriding
218(1)
Using final to Prevent Inheritance
218(1)
The Object Class
219(2)
9 Packages and Interfaces
221(26)
Packages
222(4)
Defining a Package
223(1)
Understanding CLASSPATH
224(1)
A Short Package Example
225(1)
Access Protection
226(5)
An Access Example
227(4)
Importing Packages
231(2)
Interfaces
233(14)
Defining an Interface
234(1)
Implementing Interfaces
235(3)
Applying Interfaces
238(4)
Variables in Interfaces
242(2)
Interfaces Can Be Extended
244(3)
10 Exception Handling
247(20)
Exception-Handling Fundamentals
248(1)
Exception Types
249(1)
Uncaught Exceptions
249(2)
Using try and catch
251(2)
Displaying a Description of an Exception
252(1)
Multiple catch Clauses
253(2)
Nested try Statements
255(3)
throw
258(1)
throws
259(2)
finally
261(2)
Java's Built-in Exceptions
263(1)
Creating Your Own Exception Subclasses
263(3)
Using Exceptions
266(1)
11 Multithreaded Programming
267(36)
The Java Thread Model
269(2)
Thread Priorities
269(1)
Synchronization
270(1)
Messaging
270(1)
The Thread Class and the Runnable Interface
271(1)
The Main Thread
271(3)
Creating a Thread
274(4)
Implementing Runnable
274(2)
Extending Thread
276(2)
Choosing an Approach
278(1)
Creating Multiple Threads
278(2)
Using isAlive() and join()
280(3)
Using suspend() and resume()
283(3)
Thread Priorities
286(3)
Synchronization
289(5)
Using Synchronized Methods
289(3)
The synchronized Statement
292(2)
Interthread Communication
294(8)
Deadlock
299(3)
Using Multithreading
302(1)
12 I/O, Applets, and Other Topics
303(28)
I/O Basics
304(11)
Streams
304(1)
The Stream Classes
305(1)
The Predefined Streams
305(1)
Reading Console Input
305(6)
Writing Console Output
311(4)
Reading and Writing Files
311(4)
Applet Fundamentals
315(3)
The transient and volatile Modifiers
318(1)
Using instanceof
319(3)
Native Methods
322(9)
Problems with Native Methods
326(5)
PART II The Java Library 331(364)
13 String Handling
331(28)
The String Constructors
332(3)
String Length
335(1)
Special String Operations
335(4)
String Literals
335(1)
String Concatenation
336(1)
String Concatenation with Other Data Types
336(1)
String Conversion and toString()
337(2)
Character Extraction
339(2)
charAt()
339(1)
getChars()
339(1)
getBytes()
340(1)
toCharArray()
340(1)
String Comparison
341(4)
equals() and equalsIgnoreCase()
341(1)
regionMatches()
342(1)
startsWith() and endsWith()
342(1)
equals() Versus ==
343(1)
compareTo()
344(1)
Searching Strings
345(2)
Modifying a String
347(4)
substring()
348(1)
concat()
349(1)
replace()
349(1)
trim()
350(1)
Data Conversion Using valueOf()
351(1)
Changing the Case of Characters Within a String
351(1)
StringBuffer
352(7)
StringBuffer Constructors
353(1)
length() and capacity()
353(1)
ensureCapacity()
354(1)
setLength()
354(1)
charAt() and setCharAt()
354(1)
getChars()
355(1)
append()
356(1)
insert()
357(1)
reverse()
357(2)
14 Exploring java.lang
359(42)
Simple Type Wrappers
360(13)
Number
360(1)
Double and Float
361(4)
Integer and Long
365(5)
Character
370(3)
Boolean
373(1)
Process
373(2)
Runtime
375(4)
Memory Management
377(1)
Executing Other Programs
378(1)
System
379(4)
Using currentTimeMillis() to Time Program Execution
381(1)
Using arraycopy()
382(1)
Environment Properties
383(1)
Object
383(1)
Using clone() and the Cloneable Interface
383(4)
Class
387(2)
ClassLoader
389(1)
Math
389(3)
Transcendental Functions
390(1)
Exponential Functions
390(1)
Rounding Functions
391(1)
Miscellaneous Math Methods
392(1)
Compiler
392(1)
Thread, ThreadGroup, and Runnable
392(8)
The Runnable Interface
392(1)
Thread
392(1)
ThreadGroup
393(7)
Throwable
400(1)
SecurityManager
400(1)
15 The Utility Classes
401(38)
The Enumeration Interface
402(2)
Vector
404
Stack
409(2)
Dictionary
411(1)
Hashtable
412(3)
Properties
415(6)
Using save() and load()
419(2)
StringTokenizer
421(2)
BitSet
423(2)
Date
425(6)
Date Comparison
429(1)
Strings and Time Zones
430(1)
Random
431(2)
Observable
433(6)
The Observer Interface
433(1)
An Observer Example
434(1)
16 Input/Output--Exploring java.io
439(30)
The Java I/O Classes and Interfaces
440(1)
File
441(5)
Directories
443(2)
FilenameFilter
445(1)
The Stream Classes
446(2)
InputStream
446(1)
OutputStream
447(1)
FileInputStream
448(3)
FileOutputStream
451(1)
ByteArrayInputStream
452(2)
ByteArrayOutputStream
454(2)
StringBufferInputStream
456(1)
Filtered Streams
456(1)
Buffered Streams
456(5)
BufferedInputStreams
456(3)
BufferedOutputStream
459(1)
PushbackInputStream
459(2)
SequenceInputStream
461(1)
PrintStream
462(1)
RandomAccessFile
463(1)
Using Stream I/O
463(4)
Improving wc()
465(1)
Using Stream Tokenizer
466(1)
Stream Benefits
467(2)
17 Networking
469(40)
Socket Overview
470(1)
Client/Server
471(1)
Reserved Sockets
471(1)
Proxy Servers
472(1)
Internet Addressing
472(1)
Domain Naming Service (DNS)
473(1)
Java and the Net
473(1)
The Networking Classes and Interfaces
473(1)
InetAddress
474(2)
Factory Methods
474(2)
Introspection
476(1)
TCP/IP Client Sockets
476(3)
Whois
478(1)
URL
479(2)
Format
479(1)
URLConnection
481(2)
TCP/IP Server Sockets
483(21)
A Caching Proxy HTTP Server
483(1)
Source Code
484(20)
Datagrams
504(1)
DatagramPacket
505(1)
Datagram Server and Client
505(2)
Net Worth
507(2)
18 The Applet Class
509(36)
Applet Basics
510(1)
The Applet Class
511(2)
Applet Architecture
513(1)
An Applet Skeleton
514(3)
Order of Applet Initialization and Termination
515(1)
Overriding update()
516(1)
Some Simple Applet Display Methods
517(2)
Requesting Repainting
519(4)
A Simple Banner Applet
521(2)
Using the Status Window
523(1)
Handling Events
524(9)
The Event Class
525(1)
Processing Mouse Events
525(4)
Handling Keyboard Events
529(4)
Understanding the HTML APPLET Tag
533(2)
CODEBASE
534(1)
CODE
534(1)
ALT
534(1)
NAME
534(1)
WIDTH
534(1)
ALIGN
534(1)
VSPACE and HSPACE
535(1)
PARAM NAME and VALUE
535(1)
Handling Older Browsers
535(1)
Passing Parameters to Applets
535(4)
Improving the Banner Applet
537(2)
Understanding getCodeBase() and getDocumentBase()
539(1)
AppletContext and showDocument()
540(2)
The AudioClip Interface
542(1)
The AppletStub Interface
543(1)
Outputting to the Console
543(2)
19 Introducing the AWT: Working with Windows, Graphics, and Text
545(48)
The AWT Classes
546(1)
Window Fundamentals
546(4)
Component
549(1)
Container
549(1)
Panel
550(1)
Window
550(1)
Frame
550(1)
Canvas
550(1)
Working with Frame Windows
550(3)
Setting the Window's Dimensions
551(1)
Hiding and Showing a Window
551(1)
Setting a Window's Title
551(1)
Responding to the WINDOW_DESTROY Event
552(1)
Creating a Frame Window in an Applet
553(5)
Handling Events in a Frame Window
555
Creating a Windowed Program
561(1)
Displaying Information Within a Window
562(1)
Working with Graphics
563(7)
Drawing Lines
563(1)
Drawing Rectangles
564(2)
Drawing Ellipses and Circles
566(1)
Drawing Arcs
567(1)
Drawing Polygons
568(1)
Sizing Graphics
569(1)
Working with Color
570(4)
Color Methods
571(1)
Setting the Current Graphics Color
572(1)
A Color Demonstration Applet
572(2)
Setting the Paint Mode
574(1)
Working with Fonts
575(6)
Determining the Available Fonts
577(1)
Creating and Selecting a Font
578(1)
Obtaining Font Information
580(1)
Managing Text Output Using FontMetrics
581(10)
Displaying Multiple Lines of Text
584(2)
Centering Text
586(1)
Multiline Text Alignment
587(4)
Exploring Text and Graphics
591(2)
20 Using AWT Controls, Layout Managers, and Menus
593(56)
Control Fundamentals
594(4)
Adding and Removing Controls
594(1)
Responding to Controls
595(1)
A Closer Look at Event
595(3)
Labels
598(2)
Using Buttons
600(3)
Applying Check Boxes
603(3)
CheckboxGroup
606(2)
Choice Controls
608(3)
Using Lists
611(3)
Managing Scroll Bars
614(4)
Using a TextField
618(3)
Using a TextArea
621(2)
Understanding Layout Managers
623(11)
FlowLayout
623(3)
BorderLayout
626(2)
Using Insets
628(1)
GridLayout
629(2)
CardLayout
631(3)
Using Menu Bars and Menus
634(6)
Dialog Boxes
640(6)
FileDialog
646(2)
Exploring the Controls, Menus, and Layout Managers
648(1)
21 Images
649(46)
File Formats
650(1)
Image Fundamentals: Creating, Loading, and Displaying
651(3)
Creating an Image Object
651(1)
Loading an Image
652(1)
Displaying an Image
652(2)
ImageObserver
654(5)
ImageObserver Example
656(3)
Double Buffering
659(3)
Media Tracker
662(4)
ImageProducer
666(3)
MemoryImageSource
667(2)
ImageConsumer
669(2)
PixelGrabber
669(2)
ImageFilter
671(16)
CropImageFilter
672(2)
RGBImageFilter
674(13)
Cell Animation
687(8)
PART III Software Development Using Java 695(52)
22 Development Environments
695(52)
Symantec Cafe
696(3)
Project Wizard
696(1)
Resource Editor for Menus and Forms
697(1)
Hierarchy Editor
697(2)
Microsoft J++
699(6)
Class Browsing
699(1)
Building a Sample Applet
700(2)
Connecting Java and VBScript
702(1)
Connecting Java and ActiveX
703(2)
Java WorkShop
705(3)
The Java Developer's Kit (JDK)
708(5)
Windows 95/NT, UNIX (Solaris), and Macintosh
708(1)
Linux
709(1)
Silicon Graphics
709(1)
Other Operating Systems and Environments
709(1)
Installation
709(3)
First-Time Use
712(1)
Java Packaging Techniques
713(2)
Microsoft CAB
713(2)
ZIP
715(1)
Other Products and Pointers
715(2)
23 Migrating from C++ to Java
717(30)
The Differences Between C++ and Java
718(3)
What Java Has Removed from C++
718(1)
New Features Added by Java
719(2)
Features That Differ
721(1)
Eliminating Pointers
721(6)
Converting Pointer Parameters
722(2)
Converting Pointers that Operate on Arrays
724(3)
C++ Reference Parameters Versus Java Reference Parameters
727(4)
Converting C++ Abstract Classes into Java Interfaces
731(4)
Converting Default Arguments
735(2)
Converting C++ Multiple-Inheritance Hierarchies
737(2)
Destructors Versus Finalization
739(8)
PART IV Applying Java 747(120)
24 The Dynamic Billboard Applet
747(36)
The APPLET Tag
748(2)
Source Code Overview
750(30)
DynamicBillboard.java
750(8)
BillData.java
758(2)
BillTransition.java
760(2)
ColumnTransition.java
762(3)
FadeTransition.java
765(4)
SmashTransition.java
769(3)
TearTransition.java
772(4)
UnrollTransition.java
776(4)
Dynamic Code
780(3)
25 ImageMenu: An Image-Based Web Menu
783(10)
The Source Image
785(1)
The APPLET Tags
786(1)
The Methods
787(5)
init()
787(1)
update()
788(1)
lateInit()
788(1)
paint()
788(1)
mouseExit()
788(1)
mouseDrag()
789(1)
mouseMove()
789(1)
mouseUp()
789(1)
The Source Code
789(3)
Summary
792(1)
26 The Lavatron Applet: A Sports Arena Display
793(12)
How Lavatron Works
795(1)
The Code
796(7)
The Lavatron APPLET Tag
796(1)
Lavatron.java
796(5)
IntHash()
801(2)
Hot Lava
803(2)
27 Scrabblet: A Multiplayer Crossword Game
805(62)
Network Security Concerns
806(1)
The Game
807(5)
Scoring
808(4)
The Applet Code
812(45)
The APPLET Tag
812(1)
Scrabblet.java
813(12)
IntroCanvas.java
825(2)
Board.java
827(17)
Bag.java
844(2)
Letter.java
846(5)
ServerConnection.java
851(6)
The Server Code
857(8)
Server.java
857(4)
ClientConnection.java
861(4)
Enhancing Scrabblet
865
Appendix Using Java's Documentation Comments 867(6)
The javadoc Tags 868(1)
@author 868(1)
@exception 869(1)
@see 869(1)
@param 869(1)
@return 869(1)
@version 870(1)
The General Form of a Documentation Comment 870(1)
What javadoc Outputs 870(1)
An Example that Uses Documentation Comments 871(1)
Index 873

Customer Reviews

Most Helpful Customer Reviews

See All Customer Reviews