Complete Contents

Preface
Acknowledgments
Part 1. Language
Chapter 1. What Can Java Do for Me?
What Java Does for You: Software Portability
Why Portability Matters
Java and jobs
Java and Microsoft
Language and Libraries
What a language is
What a library is
What the run-time library is
One Size Doesn't Fit All
Micro Edition (the “small” platform)
Standard Edition (the “medium” platform)
Enterprise Edition (the “large” platform)
Some Light Relief—A Java Desktop Application
Chapter 2. Introducing Objects
Downloading and Compiling Java
Downloading a Java compiler system
Compiling a Java program
Running a Java program
What Is a Class?
Declaring a variable
Simple types
Composite types
Organizing data and methods into larger “chunks”
What Is an Object?
What “reference type” really means
The big difference between primitive and object
The “null” reference
Why Java uses reference types
Choosing which Object will be operated on
Accessing a member from inside a class versus outside a class
Java Digital Clock Program
The main() routine where execution starts
The clock class
The ClockView class
Compiling and running the Digital Clock program
Summary
Exercises
Some Light Relief—Napster and LimeWire
Chapter 3. Primitive Types, Wrappers, and Boxing
Literal Values
boolean
char
int
long
byte
short
Limited Accuracy of Floating Point Types
double
float
Object Wrappers for Primitives
Autoboxing and Unboxing
Performance Implications of Autoboxing
java.lang.Object
String toString();
boolean equals(Object obj)
int hashCode ()
final Class getClass()
java.lang.String
Language Support for String Concatenation
String Comparison
Some Light Relief—Hatless Atlas
Chapter 4. Statements and Comments
Organizing Statements
Empty statement
Expression Statements
Selection Statements
Statement Notes
Looping Statements
Transfer of Control Statements
Comments
Javadoc comments
Reading the Java API
Format of Javadoc comments
Exercises
Some Light Relief—MiniScribe: The Hard Luck Hard Disk
Chapter 5. OOP Part II—Constructors and Visibility
Polymorphism Is a Long Word for a Short Topic
Object-oriented programming: key ideas so far
Reminder: Java object variables are really references to objects
Creating New Objects: Constructors
The default no-arg constructor
When not to allow a no-arg constructor
When you want it all
Constructors can call sibling constructors
A second glimpse at inheritance
What happens during instantiation
No destructors
More About Methods
Arguments and parameters
Overloaded method names
Variable-Arity Methods
Packages
What a package is
Package naming rules
Packaging classes
Creating unique package names
How the JDK Finds Classes
How to create a jar file
Making jar files double-clickable
Putting the jar file where Java will find it
Telling Java where to look for the jar file or package roots
Access Modifiers
Access modifiers for a class
Access modifiers for a method, field, or nested class
Exercises
Some Light Relief—It's Not Your Father's IBM
Chapter 6. Static, Final, and Enumerated Types
What Field Modifier static Means
What you can make static
Static data
Static methods
What Field Modifier final Means
The “blank final variable”
Why Enumerate a Type?
Drawbacks of using ints to enumerate
How enums solve these issues
How enums are implemented
Enum constants make software more reliable
Statements Updated for Enumerations
Using a for statement with enums
The values() method for enums
Using a switch statement with enums
Dropping the need to qualify names—import
Using “import static”
More Complicated Enumerated Types
Adding constructors to your enums
Instance methods and enum variables
Constant-specific class bodies
Some Light Relief—The Haunted Zen Garden of Apple
Chapter 7. Names, Operators, and Accuracy
Keywords
Punctuation Terminology
Names
Identifiers
When a field or method can be forward-referenced
When a class can be forward-referenced
Expressions
Arrays
Operators
Java operators
The ++ and -- operators
The % and / operators
The << >> and >>> operators
The instanceof Operator
The & | and ^ operators
The && and || Operators
The ? : operator
The assignment operators
The comma operator is gone
Associativity
How Accurate Are Calculations?
The precision of an expression
Limited significant figures in floating-point numbers
Inaccuracies of floating-point numbers
Floating-point extension
Widening and Narrowing Conversions
What Happens on Overflow?
Integer overflow
Floating-point overflow
Arithmetic that cannot overflow
Some Light Relief—Furby's Brain Transplant
Chapter 8. More OOP—Extending Classes
Inheritance
Real-world example of inheritance
A Java example of inheritance
Choosing the right parent saves a lot of work
The super keyword is not really very super
What happens when data field names collide?
Objects keep their identity, regardless of reference type!
Casting
Polymorphism
Overloading
Overriding
Inheriting from Object
Forcing overriding off: final
Forcing overriding on: abstract
The Class Whose Name Is Class
Exercises
Some Light Relief—The Nerd Detection System
Chapter 9. Arrays
Understanding and Creating Arrays
Arrays are objects
Index checking
Creating an array
Array compatibility
Initializing an array
Duplicating arrays
Arrays of Arrays
Array terminology
Declaring arrays of arrays
Looping over arrays
More about arrays of arrays
Have Array Brackets, Will Travel
The Math Package
Some Light Relief—Think Big (and Small)
Chapter 10. Exceptions
Run-time Internals: The Heap
Memory is allocated implicitly by creating an object
A heap of memory
Storage lifetime
Garbage Collection
Solving the fragmentation problem
The costs and benefits of garbage collection
Finalizers
Weak references
Run-time Internals: The Stack
Exceptions
The purpose of exceptions
What happens when an exception is thrown
How to cause an exception (implicitly and explicitly)
Example of causing an exception
User-defined exceptions
How to handle (“catch”) an exception within the method where it was thrown
Handling groups of related exceptions
How the exception propagates if not handled in the method where it was thrown
How and why methods declare the exceptions that can propagate out of them
Fancy exception stuff
Summary of exceptions
The Assert Statement
Two key steps in using assert
Complete example of assert
Points to watch with assert
Further Reading
Some Light Relief—Making an Exception for You
Chapter 11. Interfaces
What Problem Does an Interface Solve?
Interface java.lang.Comparable
Interfaces Versus Abstract Classes
Granting Permission Through an Interface—Cloneable
What Protected Really Means
Using Interface Callbacks for GUI Event Handlers
The Class Double
Exercises
Some Light Relief—The Java-Powered Toaster
Chapter 12. Nested Classes
Introduction to Nested Classes
Nested Static Classes
Qualities of a nested static class
Where to use a nested static class
Example of a nested static class
Inner Member Classes
Qualities of an inner member class
Where to use an inner member class
Example inner member class from the Java run-time library
Inner Local Classes
Qualities of an inner local class
Where to use an inner local class
Example inner local class
Inner Anonymous Classes
Qualities of an inner anonymous class
Where to use an inner anonymous class
Example inner anonymous class
How Inner Classes Are Compiled
The Class Character
Java coding style
Exercises
Some Light Relief—The Domestic Obfuscated Java Code Non-Competition
Part 2. Key Libraries
Chapter 13. Doing Several Things at Once: Threads
What Are Threads?
Two Ways to Obtain a New Thread
A few words on Runnable
The Lifecycle of a Thread
Priorities
Thread Groups
How many threads?
Four Kinds of Threads Programming
Unrelated threads
Related but unsynchronized threads
Some Light Relief—The Motion Sensor Solution
Chapter 14. Advanced Thread Topics
Mutually Exclusive Threads
The problem is a race condition
Synchronized blocks
Communicating Mutually Exclusive Threads
Interrupting a thread
Piped I/O for Threads
Thread Local Storage
Package java.util.concurrent
An Aside on Design Patterns
Further Reading
Exercises
Some Light Relief—Are You Certifiable? I Am.
Sun Certified Java Programmer
Chapter 15. Explanation <Generics>
Terminology Refresher: Parameters Versus Arguments
The Problem that Generic Code Addresses
What Generic Code Looks Like
Declaring a class with generic type parameters
Instantiating an object and passing arguments to the generic type
Invoking methods on objects of the instantiated generic type
Generic Interfaces
java.lang.Comparable without generics
Adding generics to java.lang.Comparable
Restrictions on a generic type
Bounds—Requiring a Type Parameter to Implement an Interface or Extend a Parent Class
Generic parameter bounds that mention a generic type
Several generic parameter bounds
Some Light Relief—On Computable Numbers with an Application to the Entscheidungsproblem
Part 3. Server-side Java
Chapter 16. Collections
Collection API
The Collection interface
Adding to a Collection
Foreach statement—iterating through a Collection
public interface Iterator <E>
List, LinkedList, and ArrayList
ArrayList implements List
Set, HashSet, and SortedSet
TreeSet
The Collections Helper Class
Comparable and Comparator
Wildcard Parameters and Generic Methods
Wildcarding a Generic Parameter
Bounds on wildcards
Lower bounds on wildcards
Generic Methods
Combining a generic method with a wildcard
Summary of Collection
Map, HashMap, and TreeMap
HashMap implements Map
TreeMap
Exercises
Some Light Relief—Early Names for Java
Chapter 17. Simple Input Output
Getting to Know Java I/O
Java I/O problems
Purpose of java.io package
Design Philosophy
Portability of I/O
The Class java.io.File
Public members of java.io.File
FileDescriptor
Keyboard I/O
System.in, out, and err
Keyboard input
The class java.util.Scanner
Keyboard output
Format specifiers—class java.util.Formatter
Other fields in a format specifier String
Output
Readers versus OutputStreams
Practical examples of output
java.io.DataOutputStream for binary output
java.io.PrintStream for printable ASCII output
Methods of java.io.PrintWriter for 16-bit character output
Wrapping Additional Output Classes
Additional writer wrappers
A Filter to replace chars
A class that uses a Filter
Output Stream wrappers
Example of outputting a zip file
Input
Inputting double-byte characters
Basic Reader methods
An input problem rears its ugly head
Reader Wrappers
Classes that wrap readers
Inputting ASCII Characters and Binary Values
Basic InputStream methods
A word about IOExceptions
Dumping a file to hexadecimal example
Input Stream Wrappers
gzip files and streams
Further Reading
Exercises
Some Light Relief—The Illegal Prime Number!
Chapter 18. Advanced Input Output
Random Access File
class java.io.RandomAccessFile
Running Commands and Getting Output From Them
Executing the attrib command from Java
Limitations on running processes
Formatted String Output
Writing Objects to Disk
Serializing and security
XML support class
New I/O Package
Multiplexed non-blocking server I/O
Non-blocking
Non-polling
Get a channel from a socket
Recovering from blocked server I/O
Workaround to blocking I/O
Getting and using a file channel
Buffers
Read a file using a Channel and a Buffer
Other Buffer methods
View Buffers
A bulk transfer from a buffer to an int array
View buffers and characters
Memory Mapped I/O
It came from Multics
Direct buffers
Mapped I/O example
File Locking
Charsets and Endian-ness
Big-endian storage
Little-endian storage
Supported encodings
Using a specific character set
Byte-swapping binary data
Summary of charsets
Exercises
Some Light Relief—The Illegal T-shirt!
Part 4. Client Java
Chapter 19. Regular Expressions
Regular Expressions And Pattern Matching
Matching a pattern
Forming patterns
Range
Single-character metacharacters
Quantifiers
Capturing groups and back references
Anchors
Alternation
Word negation
Metawords
Java grep program
Calendar Utilities
Calendar and Gregorian calendar
Other Utility Classes
BitSet
Stack
The java.math API
Random
Properties
The java.util.Properties class
Note on the Java native interface
Further Reading
Exercises
Some Light Relief—Exchanging Apples And Crays
Chapter 20. GUI Basics and Event Handling
All About Event Handling
Java event model
The JFrame example
Tips for Slimming Down Handler Code
Making a top-level class into a listener
Using a listener adapter class
Summary of Event Handling
Exercises
Some Light Relief—The Mouse That Roared
Chapter 21. JFC and the Swing Package
Java Foundation Classes
Some terminology
Overview of JComponent
All About Controls (JComponents)
How to display components
Swing Threads—A Caution!
Swing Components
JLabel
JButton
JToolTip
JTextField
JCheckBox
JPanel
JRadioButton and ButtonGroup
JOptionPane
JScrollPane
JTabbedPane
JEditorPane
More About Swing Components
Further Reading
Exercises
Some Light Relief—The Bible Code
Chapter 22. Containers, Layouts, and AWT Loose Ends
Pluggable Look and Feel
All About Containers
The Container class hierarchy
What's in a Swing container?
JFrame
JPanel
Applet and JApplet
Popular Applet methods
Window and JWindow
Layout in a Container
FlowLayout
GridLayout
BorderLayout
BoxLayout
Combining layouts
Other layout managers
Tying up the Loose Ends
JDK 1.4 image I/O
The toolkit
Printing the screen
Changing cursor appearance
Exercises
Some Light Relief—Sky View Cafe: A High Quality Applet
Part 5. Enterprise Java
Chapter 23. Relational Databases and SQL
Introduction to Relational Databases
The relational database concept
What is a table?
Tricky terminology
Mathematics makes databases work perfectly
Database design
Primary and Foreign Keys
Primary keys
Foreign keys
Referential integrity
Entity and transaction integrity
Relationships
One-to-one relationships
One-to-many relationships
Many-to-many relationships
Solving the key problem of many-to-many
Adding a table
Normal Forms
Second normal norm
Third normal norm
Add tables to taste
Relational Database Glossary
Download and Install Mckoi
Set up the Mckoi jar files
Running the Mckoi example code
Running the Mckoi SQL query tool
Basic SQL Primer
Creating and Populating Tables
Querying and Retrieving Data
Subquery Selections
Result Set of a SELECT Query
Contents of a result set
The cursor
Getting a sorted result set
SELECT pitfalls
Updating Values
Deleting Records and Tables
SQL Prepared Statements and Stored Procedures
Prepared statement
Stored procedure
Exercises
Some Light Relief—Reading the Docs
Chapter 24. JDBC
Introduction to JDBC
Installing the Mckoi Database Software
Running the Example Code
Connecting to the Database
Load a JDBC driver
Get a database connection using a URL-like string
Executing SQL Statements
Threads and database programming
Result Sets
Cursor support
Batching SQL Statements and Transactions
Transactions
Prepared Statements and Stored Procedures
Prepared statements
Stored procedures
Complete Example
Database and Result Set Metadata
Further Reading
Exercises
Heavy Light Relief—In Which “I” Spam Myself
Managing files is worth paying for
Spam, spam, spam, lovely spam
Blacklisting a clueless ISP
It's got to stop
TIP: Trusted Internet Protocol
Chapter 25. Networking in Java
Everything You Need To Know about TCP/IP but Failed to Learn in Kindergarten
Please do not teach students poor acronyms
The TCP/IP four-layer reality
Protocols built on IP
Client versus server sockets
IPv4 versus IPv6
Common network hardware
What's in the networking library?
TCP/IP client/server model
A Client Socket in Java
Sending Email by Java
A Server Socket in Java
Socket protocols
Running the HTTP server program
Debugging sockets
Getting the HTTP command
HTTP and Web Browsing: Retrieving HTTP Pages
How to find the IP address given to a machine name
A Multithreaded HTTP Server
A Mapped I/O HTTP Server
Further Reading
Exercises
Some Light Relief—500 Mile Limit on Email
Chapter 26. Servlets and JSP
Overview of Servlets and JSP
Servlets for creating web pages with the latest data
JavaServer Pages for embedding dynamic web page content
Why Use Servlets?
Clients and servers
What servlets replace
Servlets as web services
“Apps on tap”—provisioning
Releases and Versions
Installing the Tomcat Software
Running the Example Servlets
Ports and Protocols
The HTML to Invoke a Servlet
How form data is sent to a URL
Differences between POST and GET
The HTTP response
A Servlet and Its Request/Response
Servlet Request
Response to a Servlet Request
Writing Your Own Servlet
Compiling your servlet
MIME—Multipurpose Internet Mail Exchange
HTTP versions 1.0 and 1.1
Keeping track of content length
Three servlet tips
Configuring Tomcat to find your servlet
Browser results from running the servlet
Servlet deployment
Servlet Operating Cycle and Threading
Servlet life cycle
Servlets and threads
Additional servlet information
Java Server Pages
A JSP is a slick way of writing a servlet
JSP syntax
Second example of JSP
Use Struts to avoid JSP tangles
Java Beans in Servlets and JSP
Last Words on JSP, Beans, and Tag Libraries
Further Reading
Exercises
Some Light Relief—Using Java to Stuff an Online Poll
What this was all about
The Java votebot
Chapter 27. XML and Java
XML Versus HTML
XML advantages over HTML
HTML—a good display format and not much else
XML does things that HTML cannot
Don't double-wrap data; transform it
Some Rules of XML
The XML element
XML attributes
XML comments
Well-formed XML documents
The Document Type Definition (DTD)
What a DTD does
DTD syntax
XML documents are trees
Sections of an XML document
XML and namespaces
DTD for Shakespeare's plays
What Is XML Used For?
The origins of XML
XML solves data incompatibility
XML means we can all just get along
Requirements for B2B XML processes
XML Versions and Glossary
JAXP Library Contents
Reading XML With DOM Parsers
A Program That Uses a DOM Parser
Reading an XML File—SAX Parsers
A Program That Uses a SAX Parser
The Factory Design Pattern
Design Pattern Summary
Other Java XML Notes
Further Reading
Exercises
Some Light Relief—View Source on Kevin's Life
Chapter 28. Web Services at Google and Amazon
Web Services Introduction
The problem that web services solve
Web services infrastructure
Web services and your code
Google Web Services
Contents of the Google Beta Kit
The googleapi.jar library
The Google WSDL file
Running the example program
Coding your own Google search
Amazon Web Services
Contents of the Amazon Beta Kit
Running the example program
A more RESTful way to access Amazon web services
Conclusions
Some Light Relief—Googlewhacking
Appendix A. Downloading Java
Appendix B. Powers of Two Table
Appendix C. Codesets
Index
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.14.240.252