did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

We're the #1 textbook rental company. Let us show you why.

9780321334206

The Java Tutorial A Short Course on the Basics

by ; ; ; ; ;
  • ISBN13:

    9780321334206

  • ISBN10:

    0321334205

  • Edition: 4th
  • Format: Paperback
  • Copyright: 2006-09-29
  • Publisher: Addison-Wesley Professional
  • View Upgraded Edition
  • Purchase Benefits
  • Free Shipping Icon Free Shipping On Orders Over $35!
    Your order must be $35 or more to qualify for free economy shipping. Bulk sales, PO's, Marketplace items, eBooks and apparel do not qualify for this offer.
  • eCampus.com Logo Get Rewarded for Ordering Your Textbooks! Enroll Now
List Price: $59.99

Summary

This hands-on introduction to the Java programming language has been updated for J2SE 5.0 and written by the members of the Java Software team. It uses an interactive approach to help new programmers learn by example.

Author Biography

Sharon Zakhour, the Java Tutorial team lead, has worked at Sun Microsystems as a senior technical writer for seven years. She graduated from UC Berkeley with a B.A. in computer science and has worked as a programmer, developer support engineer, and technical writer for more than twenty years.

Scott Hommel is a technical writer on staff at Sun Microsystems, where he documents the Java Platform, Standard Edition. Since 1999, he has contributed to every major release of the JDK, mostly in the form of API spec clarifications and core release documentation.

Jacob Royal has an M.S. in IT and an M.B.A. in information systems. He has written administrator's guides, API references and programmer's guides, and has identified new tools and developed code and writing standards for various companies, including Lucent Technologies and Autodesk.

Isaac Rabinovitch is a freelance technical writer. He has written user manuals, programmer's guides, administrator's manuals, API references, release notes, and support documentation at Sun Microsystems, Borland, SGI, and many other companies.

Thomas Risser was educated in physics at Harvard (B.A.) and the University of California at Berkeley (Ph.D.). He has been a technical writer in the computer industry for fifteen years.

Mark Hoeber is a former senior technical writer at Sun Microsystems. He has worked as a technical writer for twelve years, focusing on documentation for software developers and system administrators.

Table of Contents

Foreword xix
Preface xxi
Getting Started
1(32)
The Java Technology Phenomenon
1(5)
About the Java Technology
1(3)
What Can Java Technology Do?
4(1)
How Will Java Technology Change My Life?
5(1)
The ``Hello World!'' Application
6(18)
``Hello World!'' for the NetBeans IDE
6(8)
``Hello World!'' for Microsoft Windows
14(5)
``Hello World!'' for Solaris OS and Linux
19(5)
A Closer Look at the ``Hello World!'' Application
24(3)
Source Code Comments
24(1)
The HelloWorldApp Class Definition
25(1)
The main Method
25(2)
Common Problems (and Their Solutions)
27(3)
Compiler Problems
27(2)
Runtime Problems
29(1)
Questions and Exercises: Getting Started
30(3)
Object-Oriented Programming Concepts
33(10)
What Is an Object?
33(2)
What Is a Class?
35(2)
What Is Inheritance?
37(1)
What Is an Interface?
38(1)
What Is a Package?
39(1)
Questions and Exercises: Object-Oriented Programming Concepts
40(3)
Language Basics
43(42)
Variables
43(12)
Naming
44(1)
Primitive Data Types
45(4)
Arrays
49(4)
Summary of Variables
53(1)
Questions and Exercises: Variables
54(1)
Operators
55(11)
Assignment, Arithmetic, and Unary Operators
56(3)
Equality, Relational, and Conditional Operators
59(3)
Bitwise and Bit Shift Operators
62(1)
Summary of Operators
63(1)
Questions and Exercises: Operators
64(2)
Expressions, Statements, and Blocks
66(3)
Expressions
66(1)
Statements
67(1)
Blocks
68(1)
Questions and Exercises: Expressions, Statements, and Blocks
68(1)
Control Flow Statements
69(16)
The if-then and if-then-else Statements
69(2)
The switch Statement
71(3)
The while and do-while Statements
74(1)
The for Statement
75(2)
Branching Statements
77(5)
Summary of Control Flow Statements
82(1)
Questions and Exercises: Control Flow Statements
82(3)
Classes and Objects
85(54)
Classes
85(12)
Declaring Classes
87(1)
Declaring Member Variables
88(2)
Defining Methods
90(2)
Providing Constructors for Your Classes
92(1)
Passing Information to a Method or a Constructor
93(4)
Objects
97(9)
Creating Objects
99(4)
Using Objects
103(3)
More on Classes
106(16)
Returning a Value from a Method
106(3)
Using the this Keyword
109(1)
Controlling Access to Members of a Class
110(2)
Understanding Instance and Class Members
112(5)
Initializing Fields
117(1)
Summary of Creating and Using Classes and Objects
118(1)
Questions and Exercises: Classes
119(2)
Questions and Exercises: Objects
121(1)
Nested Classes
122(6)
Why Use Nested Classes?
122(1)
Static Nested Classes
123(1)
Inner Classes
123(1)
Inner Class Example
124(3)
Summary of Nested Classes
127(1)
Questions and Exercises: Nested Classes
128(1)
Enum Types
128(4)
Questions and Exercises: Enum Types
132(1)
Annotations
132(7)
Documentation
133(1)
Annotations Used by the Compiler
134(2)
Annotation Processing
136(1)
Questions and Exercises: Annotations
136(3)
Interfaces and Inheritance
139(28)
Interfaces
139(8)
Interfaces in Java
140(1)
Interfaces as APIs
141(1)
Interfaces and Multiple Inheritance
141(1)
Defining an Interface
142(1)
Implementing an Interface
143(2)
Using an Interface as a Type
145(1)
Rewriting Interfaces
146(1)
Summary of Interfaces
146(1)
Questions and Exercises: Interfaces
147(1)
Inheritance
147(20)
The Java Platform Class Hierarchy
148(1)
An Example of Inheritance
148(2)
What You Can Do in a Subclass
150(1)
Private Members in a Superclass
151(1)
Casting Objects
151(1)
Overriding and Hiding Methods
152(2)
Hiding Fields
154(1)
Using the Keyword super
154(2)
Object as a Superclass
156(4)
Writing Final Classes and Methods
160(1)
Abstract Methods and Classes
161(3)
Summary of Inheritance
164(1)
Questions and Exercises: Inheritance
164(3)
Generics
167(16)
Introduction
167(2)
A Simple Box Class
168(1)
Generic Types
169(3)
Type Parameter Conventions
171(1)
Generic Methods and Constructors
172(1)
Bounded Type Parameters
173(2)
Subtyping
175(2)
Wildcards
177(1)
Type Erasure
178(1)
Summary of Generics
179(1)
Questions and Exercises: Generics
180(3)
Packages
183(12)
Creating and Using Packages
183(12)
Creating a Package
184(2)
Naming a Package
186(1)
Using Package Members
187(4)
Managing Source and Class Files
191(2)
Summary of Creating and Using Packages
193(1)
Questions and Exercises: Creating and Using Packages
194(1)
Numbers and Strings
195(38)
Numbers
195(15)
The Numbers Classes
195(3)
Formatting Numeric Print Output
198(5)
Beyond Basic Arithmetic
203(5)
Summary of Numbers
208(1)
Questions and Exercises: Numbers
209(1)
Characters
210(2)
Escape Sequences
212(1)
Strings
212(21)
Creating Strings
213(1)
String Length
213(1)
Concatenating Strings
214(1)
Creating Format Strings
215(1)
Converting Between Numbers and Strings
216(2)
Manipulating Characters in a String
218(6)
Comparing Strings and Portions of Strings
224(2)
The StringBuilder Class
226(4)
Summary of Characters and Strings
230(1)
Questions and Exercises: Characters and Strings
231(2)
Exceptions
233(28)
What Is an Exception?
233(2)
The Catch or Specify Requirement
235(1)
The Three Kinds of Exceptions
235(1)
Bypassing Catch or Specify
236(1)
Catching and Handling Exceptions
236(9)
The try Block
238(1)
The catch Blocks
239(1)
The finally Block
240(1)
Putting It All Together
241(4)
Specifying the Exceptions Thrown by a Method
245(1)
How to Throw Exceptions
246(6)
The throw Statement
247(1)
Throwable Class and Its Subclasses
247(1)
Error Class
248(1)
Exception Class
248(1)
Chained Exceptions
249(1)
Creating Exception Classes
250(2)
Unchecked Exceptions---The Controversy
252(1)
Advantages of Exceptions
253(5)
Advantage 1: Separating Error-Handling Code from ``Regular'' Code
253(2)
Advantage 2: Propagating Errors Up the Call Stack
255(2)
Advantage 3: Grouping and Differentiating Error Types
257(1)
Summary
258(1)
Questions and Exercises: Exceptions
259(2)
Basic I/O
261(32)
I/O Streams
261(25)
Byte Streams
263(2)
Character Streams
265(4)
Buffered Streams
269(1)
Scanning and Formatting
270(6)
I/O from the Command Line
276(3)
Data Streams
279(3)
Object Streams
282(4)
File I/O
286(5)
File Objects
286(3)
Random Access Files
289(2)
The New I/O Packages
291(1)
Summary
292(1)
Questions and Exercises: Basic I/O
292(1)
Collections
293(76)
Introduction to Collections
293(2)
What Is a Collections Framework?
294(1)
Benefits of the Java Collections Framework
294(1)
Interfaces
295(47)
The Collection Interface
298(3)
The Set Interface
301(5)
The List Interface
306(10)
The Queue Interface
316(3)
The Map Interface
319(9)
Object Ordering
328(7)
The SortedSet Interface
335(3)
The SortedMap Interface
338(2)
Summary of Interfaces
340(1)
Questions and Exercises: Interfaces
340(2)
Implementations
342(13)
Set Implementations
344(2)
List Implementations
346(1)
Map Implementations
347(2)
Queue Implementations
349(1)
Wrapper Implementations
350(2)
Convenience Implementations
352(2)
Summary of Implementations
354(1)
Questions and Exercises: Implementations
355(1)
Algorithms
355(5)
Sorting
356(2)
Shuffling
358(1)
Routine Data Manipulation
359(1)
Searching
359(1)
Composition
360(1)
Finding Extreme Values
360(1)
Custom Collection Implementations
360(4)
Reasons to Write an Implementation
360(1)
How to Write a Custom Implementation
361(3)
Interoperability
364(5)
Compatibility
364(2)
API Design
366(3)
Concurrency
369(36)
Processes and Threads
369(2)
Processes
370(1)
Threads
370(1)
Thread Objects
371(6)
Defining and Starting a Thread
371(1)
Pausing Execution with sleep
372(1)
Interrupts
373(2)
Joins
375(1)
The SimpleThreads Example
375(2)
Synchronization
377(7)
Thread Interference
377(2)
Memory Consistency Errors
379(1)
Synchronized Methods
380(1)
Intrinsic Locks and Synchronization
381(2)
Atomic Access
383(1)
Liveness
384(2)
Deadlock
384(1)
Starvation and Livelock
385(1)
Guarded Blocks
386(5)
Immutable Objects
391(4)
A Synchronized Class Example
391(2)
A Strategy for Defining Immutable Objects
393(2)
High-Level Concurrency Objects
395(7)
Lock Objects
395(2)
Executors
397(3)
Concurrent Collections
400(1)
Atomic Variables
401(1)
For Further Reading
402(1)
Questions and Exercises: Concurrency
403(2)
Regular Expressions
405(38)
Introduction
405(1)
What Are Regular Expressions?
405(1)
How Are Regular Expressions Represented in This Package?
406(1)
Test Harness
406(1)
String Literals
407(2)
Metacharacters
408(1)
Character Classes
409(5)
Simple Classes
410(4)
Predefined Character Classes
414(2)
Quantifiers
416(6)
Zero-Length Matches
417(3)
Capturing Groups and Character Classes with Quantifiers
420(1)
Differences among Greedy, Reluctant, and Possessive Quantifiers
421(1)
Capturing Groups
422(2)
Numbering
422(1)
Backreferences
423(1)
Boundary Matchers
424(1)
Methods of the Pattern Class
425(6)
Creating a Pattern with Flags
426(1)
Embedded Flag Expressions
427(1)
Using the matches(String, CharSequence) Method
428(1)
Using the split(String) Method
428(2)
Other Utility Methods
430(1)
Pattern Method Equivalents in java.lang.String
430(1)
Methods of the Matcher Class
431(6)
Index Methods
431(1)
Study Methods
431(1)
Replacement Methods
432(1)
Using the start and end Methods
432(2)
Using the matches and lookingAt Methods
434(1)
Using replaceFirst(String) and replaceAll(String)
434(2)
The appendReplacement(StringBuffer, String) and appendTail(StringBuffer) Methods
436(1)
Matcher Method Equivalents in java.lang.String
436(1)
Methods of the PatternSyntaxException Class
437(2)
Summary
439(1)
Additional Resources
440(1)
Questions and Exercises: Regular Expressions
440(3)
The Platform Environment
443(20)
Configuration Utilities
443(9)
Properties
443(5)
Command-Line Arguments
448(1)
Environment Variables
449(2)
Other Configuration Utilities
451(1)
System Utilities
452(5)
Command-Line I/O Objects
452(1)
System Properties
452(3)
The Security Manager
455(2)
Miscellaneous Methods in System
457(1)
Path and Classpath
457(3)
Update the Path Variable(Microsoft Windows NT/2000/XP)
458(1)
Update the Path Variable (Solaris and Linux)
458(2)
Checking the Classpath Variable (All Platforms)
460(1)
Questions and Exercises: The Platform Environment
460(3)
Swing
463(24)
A Brief Introduction to the Swing Package
463(7)
What Is Swing?
463(3)
A Swing Demo
466(4)
Swing Features
470(15)
A Visual Guide to Swing Components
470(6)
Pluggable Look and Feel
476(4)
Drag and Drop and Data Transfer
480(1)
Internationalization and Localization
480(2)
Accessibility
482(1)
Integrating with the Desktop
483(1)
System Tray Icon Support
484(1)
Questions: Graphical User Interfaces
485(2)
Packaging Programs in JAR Files
487(34)
Using JAR Files: The Basics
488(12)
Creating a JAR File
490(3)
Viewing the Contents of a JAR File
493(2)
Extracting the Contents of a JAR File
495(1)
Updating a JAR File
496(2)
Running JAR-Packaged Software
498(2)
Working with Manifest Files: The Basics
500(7)
Understanding the Default Manifest
500(1)
Modifying a Manifest File
501(1)
Setting an Application's Entry Point
502(1)
Adding Classes to the JAR File's Classpath
503(1)
Setting Package Version Information
504(2)
Sealing Packages Within a JAR File
506(1)
Signing and Verifying JAR Files
507(7)
Understanding Signing and Verification
508(3)
Signing JAR Files
511(2)
Verifying Signed JAR Files
513(1)
Using JAR-Related APIs
514(6)
An Example---The JarRunner Application
514(1)
The JarClassLoader Class
515(3)
The JarRunner Class
518(2)
Questions: JAR Files
520(1)
Java Web Start
521(22)
Running Java Web Start Applications
522(2)
Running a Java Web Start Application from a Browser
523(1)
Running an Application from the Java Cache Viewer
523(1)
Running a Java Web Start Application from the Desktop
524(1)
Deploying Java Web Start Applications
524(10)
Setting Up the Web Server
525(1)
Creating the JNLP File
525(8)
Placing the Application on the Web Server
533(1)
Creating the Web Page
534(1)
Developing Java Web Start Applications
534(2)
Packaging the Application in JAR Files
534(1)
Reading Resources in a JAR File
535(1)
Untrusted Applications
535(1)
The JNLP API
536(2)
Java Web Start and Security
538(1)
Java Web Start Security Basics
538(1)
Signing JAR Files for Java Web Start Deployment
538(1)
Security and JNLP Files
538(1)
Dynamic Downloading of HTTPS Certificates
539(1)
Common Java Web Start Problems
539(1)
Questions and Exercises: Java Web Start
540(3)
Applets
543(60)
Getting Started with Applets
545(14)
Extending Applet or JApplet
546(1)
The Life Cycle of an Applet
547(3)
Methods for Milestones
550(2)
Methods for Drawing and Event Handling
552(2)
Methods for Adding UI Components
554(4)
What Applets Can and Can't Do
558(1)
Taking Advantage of the Applet API
559(19)
Finding and Loading Data Files
560(1)
Displaying Short Status Strings
561(1)
Displaying Documents in the Browser
562(2)
Sending Messages to Other Applets
564(4)
Playing Sounds
568(2)
Defining and Using Applet Parameters
570(4)
Using the APPLET Tag
574(4)
Practical Considerations When Writing Applets
578(15)
Security Restrictions
578(3)
Creating a User Interface
581(2)
Getting System Properties
583(2)
Threads in Applets
585(4)
Working with a Server-Side Application
589(4)
Finishing an Applet
593(1)
Before You Ship That Applet
593(1)
The Perfectly Finished Applet
594(1)
Deploying Applets
594(6)
General Deployment Considerations
595(1)
Using the applet Tag
595(1)
Using the object Tag
596(2)
Using the embed Tag
598(1)
Deploying Applets in a Mixed-Browser Environment
598(2)
Solving Common Applet Problems
600(2)
Questions and Exercises: Java Applets
602(1)
Appendix A Java Language Keywords 603(2)
Appendix B Preparation for Java Programming Language Certification 605(12)
Index 617

Supplemental Materials

What is included with this book?

The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.

The Used, Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.

Excerpts

Since the release of the original Java Development Kit in May of 1995, the engineering team at Sun Microsystems has been hard at work improving and enhancing the Java platform. The publication of this edition coincides with the release of Version 6 of the Java Platform, Standard Edition (Java SE) and reflects the API of that release. This edition introduces new features added to the Java platform since the publication of the third edition (under release 1.3), such as a chapter on generics and information on annotations. There are new chapters on Java Web Start, the platform environment, and regular expressions. Most chapters, such as Concurrency (formerly Threads), I/O, Object-Oriented Programming Concepts, and Language Basics, have been completely rewritten. Collections has been brought out of the appendix and into its own chapter. A new appendix contains information on how to prepare for the Java Programming Language Certification exam. All of the material has been thoroughly reviewed by members of engineering to ensure that the information is accurate and up to date. Like the previous editions, this book is based on the online tutorial hosted at Sun Microsystems' Web site: http://java.sun.com/docs/books/tutorial/index.html The information in this book--often referred to as "the core tutorial" or "the basics"-- is required by most beginning to intermediate programmers. Once you have mastered the material in this book, you can explore the rest of the Java platform on the Web site. As always, our goal is to create an easy-to-read practical programmer's guide with lots of examples to help people learn to program. Who Should Read this Book? This book is geared toward both novice and experienced programmers. New programmers can benefit most from reading the book from beginning to end, including the step by step instructions for compiling and running your first program in Chapter 1, "Getting Started." Programmers experienced with procedural languages such as C++ may wish to start with the material on object-oriented concepts and features of the Java programming language. Experienced programmers may want to jump feet first into more advanced topics, such as generics, concurrency, or Java Web Start. This book contains information to address the learning needs of programmers with various levels of experience. How to Use This Book This book is designed so you can either read it straight through or skip around from topic to topic. The information is presented in a logical order, and forward references are avoided wherever possible. The examples in this tutorial are compiled against the 6.0 release. You need to download this release in order to compile and run most examples. The accompanying CD contains the content of this book (including examples, and answers to the questions and exercises), as well as the online-only Java SE tutorials, an early 6.0 release of the Java SE Development Kit (JDK), and the corresponding API specification and guide documentation. You will see footnotes like the following: docs/api/java/lang/Class.html and tutorial/deployment/applet/examples/TalkServer.java The highest level of the CD contains docs and tutorial directories, so those footnotes can be located on the CD as specified. To locate the latest pages online, prepend http://java.sun.com/javase/6/ to the docs footnotes and http://java.sun.com/docs/books/ to the tutorial footnotes: http://java.sun.com/javase/6/docs/api/java/lang/Class.html

Rewards Program