| help | account  


Java in a Nutshell, 5th Edition
View Larger Image
David Flanagan
O'Reilly Media, Paperback, 5th edition, Published March 2005, 1225 pages, ISBN 0596007736
List Price: $44.95
Our Price: $28.50
You Save: $16.45 (37% Off)


FREE Shipping on Orders over $40!*
Availability: In-Stock
Download an excerpt:
Chapter 5: The Java Platform — Threads and Concurrency

     

Excerpt provided courtesy of O'Reilly and Associates.

Be the First to Write a Review and tell the world about this title!

People who purchase this book frequently purchase:

Books on similar topics, in best-seller order:Books from the same publisher, in best-seller order:

With more than 700,000 copies sold to date, Java in a Nutshell from O'Reilly is clearly the favorite resource amongst the legion of developers and programmers using Java technology. And now, with the release of the 5.0 version of Java, O'Reilly has given the book that defined the "in a Nutshell" category another impressive tune-up.

In this latest revision, readers will find Java in a Nutshell, 5th Edition does more than just cover the extensive changes implicit in 5.0, the newest version of Java. It's undergone a complete makeover--in scope, size, and type of coverage--in order to more closely meet the needs to the modern Java programmer.

To wit, Java in a Nutshell, 5th Edition now places less emphasis on coming to Java from C and C++, and adds more discussion on tools and frameworks. It also offers new code examples to illustrate the working of APIs, and, of course, extensive coverage of Java 5.0. But faithful readers take comfort: it still hasn't lost any of its core elements that made it such a classic to begin with.

This handy reference gets right to the heart of the program with an accelerated introduction to the Java programming language and its key APIs--ideal for developers wishing to start writing code right away. And, as was the case in previous editions, Java in a Nutshell, 5th Edition is once again chock-full of poignant tips, techniques, examples, and practical advice.

For as long as Java has existed, Java in a Nutshell has helped developers maximize the capabilities of the program's newest versions. And this latest edition is no different.

Table of Contents

Preface

I. Introducing Java

1. Introduction

What Is Java?
The Java Programming Language
The Java Virtual Machine
The Java Platform
Versions of Java
Key Benefits of Java
Write Once, Run Anywhere
Security
Network-Centric Programming
Dynamic, Extensible Programs
Internationalization
Performance
Programmer Efficiency and Time-to-Market
An Example Program
Compiling and Running the Program
Analyzing the Program
Exceptions

2. Java Syntax from the Ground Up

Java Programs from the Top Down
Lexical Structure
The Unicode Character Set
Case-Sensitivity and Whitespace
Comments
Reserved Words
Identifiers
Literals
Punctuation
Primitive Data Types
The boolean Type
The char Type
Strings
Integer Types
Floating-Point Types
Primitive Type Conversions
Expressions and Operators
Operator Summary
Arithmetic Operators
String Concatenation Operator
Increment and Decrement Operators
Comparison Operators
Boolean Operators
Bitwise and Shift Operators
Assignment Operators
The Conditional Operator
The instanceof Operator
Special Operators
Statements
Expression Statements
Compound Statements
The Empty Statement
Labeled Statements
Local Variable Declaration Statements
The if/else Statement
The switch Statement
The while Statement
The do Statement
The for Statement
The for/in Statement
The break Statement
The continue Statement
The return Statement
The synchronized Statement
The throw Statement
The try/catch/finally Statement
The assert Statement
Methods
Defining Methods
Method Modifiers
Declaring Checked Exceptions
Variable-Length Argument Lists
Covariant Return Types
Classes and Objects Introduced
Defining a Class
Creating an Object
Using an Object
Object Literals
Arrays
Array Types
Creating and Initializing Arrays
Using Arrays
Multidimensional Arrays
Reference Types
Reference vs. Primitive Types
Copying Objects
Comparing Objects
Terminology: Pass by Value
Memory Allocation and Garbage Collection
Reference Type Conversions
Boxing and Unboxing Conversions
Packages and the Java Namespace
Package Declaration
Globally Unique Package Names
Importing Types
Importing Static Members
Java File Structure
Defining and Running Java Programs
Differences Between C and Java

3. Object-Oriented Programming in Java

Class Definition Syntax
Fields and Methods
Field Declaration Syntax
Class Fields
Class Methods
Instance Fields
Instance Methods
Case Study: System.out.println( )
Creating and Initializing Objects
Defining a Constructor
Defining Multiple Constructors
Invoking One Constructor from Another
Field Defaults and Initializers
Destroying and Finalizing Objects
Garbage Collection
Memory Leaks in Java
Object Finalization
Subclasses and Inheritance
Extending a Class
Superclasses, Object, and the Class Hierarchy
Subclass Constructors
Constructor Chaining and the Default Constructor
Hiding Superclass Fields
Overriding Superclass Methods
Data Hiding and Encapsulation
Access Control
Data Accessor Methods
Abstract Classes and Methods
Important Methods of java.lang.Object
toString()
equals( )
hashCode( )
Comparable.compareTo( )
clone()
Interfaces
Defining an Interface
Implementing an Interface
Interfaces vs. Abstract Classes
Marker Interfaces
Interfaces and Constants
Nested Types
Static Member Types
Nonstatic Member Classes
Local Classes
Anonymous Classes
How Nested Types Work
Modifier Summary
C++ Features Not Found in Java

4. Java 5.0 Language Features

Generic Types
Typesafe Collections
Understanding Generic Types
Type Parameter Wildcards
Writing Generic Types and Methods
Generics Case Study: Comparable and Enum
Enumerated Types
Enumerated Types Basics
Using Enumerated Types
Advanced Enum Syntax
The Typesafe Enum Pattern
Annotations
Annotation Concepts and Terminology
Using Standard Annotations
Annotation Syntax
Annotations and Reflection
Defining Annotation Types
Meta-Annotations

5. The Java Platform

Java Platform Overview
Text
The String Class
The Character Class
The StringBuffer Class
The CharSequence Interface
The Appendable Interface
String Concatenation
String Comparison
Supplementary Characters
Formatting Text with printf() and format( )
Logging
Pattern Matching with Regular Expressions
Tokenizing Text
StringTokenizer
Numbers and Math
Mathematical Functions
Random Numbers
Big Numbers
Converting Numbers from and to Strings
Formatting Numbers
Dates and Times
Milliseconds and Nanoseconds
The Date Class
The Calendar Class
Formatting Dates and Times
Arrays
Collections
The Collection Interface
The Set Interface
The List Interface
The Map Interface
The Queue and BlockingQueue Interfaces
Collection Wrappers
Special-Case Collections
Converting to and from Arrays
Collections Utility Methods
Implementing Collections
Threads and Concurrency
Creating, Running, and Manipulating Threads
Making a Thread Sleep
Running and Scheduling Tasks
Exclusion and Locks
Coordinating Threads
Thread Interruption
Blocking Queues
Atomic Variables
Files and Directories
RandomAccessFile
Input/Output with java.io
Reading Console Input
Reading Lines from a Text File
Writing Text to a File
Reading a Binary File
Compressing Data
Reading ZIP Files
Computing Message Digests
Streaming Data to and from Arrays
Thread Communication with Pipes
Networking with java.net
Networking with the URL Class
Working with Sockets
Secure Sockets with SSL
Servers
Datagrams
Testing the Reachability of a Host
I/O and Networking with java.nio
Basic Buffer Operations
Basic Channel Operations
Encoding and Decoding Text with Charsets
Working with Files
Client-Side Networking
Server-Side Networking
Nonblocking I/O
XML
Parsing XML with SAX
Parsing XML with DOM
Transforming XML Documents
Validating XML Documents
Evaluating XPath Expressions
Types, Reflection, and Dynamic Loading
Class Objects
Reflecting on a Class
Dynamic Class Loading
Dynamic Proxies
Object Persistence
Serialization
JavaBeans Persistence
Security
Message Digests
Digital Signatures
Signed Objects
Cryptography
Secret Keys
Encryption and Decryption with Cipher
Encrypting and Decrypting Streams
Encrypted Objects
Miscellaneous Platform Features
Properties
Preferences
Processes
Management and Instrumentation

6. Java Security

Security Risks
Java VM Security and Class File Verification
Authentication and Cryptography
Access Control
Java 1.0: The Sandbox
Java 1.1: Digitally Signed Classes
Java 1.2: Permissions and Policies
Security for Everyone
Security for System Programmers
Security for Application Programmers
Security for System Administrators
Security for End Users
Permission Classes

7. Programming and Documentation Conventions

Naming and Capitalization Conventions
Portability Conventions and Pure Java Rules
Java Documentation Comments
Structure of a Doc Comment
Doc-Comment Tags
Inline Doc Comment Tags
Cross-References in Doc Comments
Doc Comments for Packages
JavaBeans Conventions
Bean Basics
Bean Classes
Properties
Indexed Properties
Bound Properties
Constrained Properties
Events

8. Java Development Tools

apt
extcheck
jarsigner
jar
java
javac
javadoc
javah
javap
javaws
jconsole
jdb
jinfo
jmap
jps
jsadebugd
jstack
jstat
jstatd
keytool
native2ascii
pack200
policytool
serialver
unpack200

II. API Quick Reference

How to Use This Quick Reference

9. java.io

10. java.lang and Subpackages

11. java.math

12. java.net

13. java.nio and Subpackages

14. java.security and Subpackages

15. java.text

16. java.util and Subpackages

17. javax.crypto and Subpackages

18. javax.net and javax.net.ssl

19. javax.security.auth and Subpackages

20. javax.xml and Subpackages

21. org.w3c.dom

22. org.xml.sax and Subpackages

Class, Method, and Field Index

Index

About the Author

David Flanagan is a computer programmer who spends most of his time writing about JavaScript and Java. His books with O'Reilly include Java in a Nutshell, Java Examples in a Nutshell, Java Foundation Classes in a Nutshell, JavaScript: The Definitive Guide, and JavaScript Pocket Reference. David has a degree in computer science and engineering from the Massachusetts Institute of Technology. He lives with his wife and son in the U.S. Pacific Northwest bewteen the cities of Seattle, Washington and Vancouver, British Columbia. David has a simple website at http://www.davidflanagan.com.




Forgot your password?
FAQs
Shipping Options
Returns
Your Orders
Your Account