Home > Store

Sams Teach Yourself Java 2 in 21 Days, 4th Edition

Register your product to gain access to bonus material or receive a coupon.

Sams Teach Yourself Java 2 in 21 Days, 4th Edition

Premium Website

  • Sorry, this book is no longer in print.
Not for Sale


  • Copyright 2004
  • Edition: 4th
  • Premium Website
  • ISBN-10: 0-672-32628-0
  • ISBN-13: 978-0-672-32628-8

Sams Teach Yourself Java 2 in 21 days, Fourth Edition continues to be one of the most popular, best-selling Java tutorials on the market. Written by an expert technical writer, it has been acclaimed for its clear and personable writing, for its extensive use of examples, and for its logical and complete organization. This new edition of the book maintains and improves upon all these qualities, while updating, revising, and reorganizing the material to cover the latest developments in Java and to expand the coverage of core Java programming topics.

Sample Content

Online Sample Chapters

Working with Objects

Working with Objects in Java Programming

Table of Contents



Day 1. Getting Started with Java.

The Java Language. Object-Oriented Programming. Objects and Classes. Attributes and Behavior. Organizing Classes and Class Behavior. Summary. Q&A. Quiz. Exercises.

Day 2. The ABCs of Programming.

Statements and Expressions. Variables and Data Types. Comments. Literals. Expressions and Operators. String Arithmetic. Summary. Q&A. Quiz. Exercises.

Day 3. Working with Objects.

Creating New Objects. Accessing and Setting Class and Instance Variables. Calling Methods. References to Objects. Casting and Converting Objects and Primitive Types. Comparing Object Values and Classes. Summary. Q&A. Quiz. Exercises.

Day 4. Lists, Logic, and Loops.

Arrays. Block Statements. if Conditionals. switch Conditionals. for Loops. while and do Loops. Breaking Out of Loops. Summary. Q&A. Quiz. Exercises.

Day 5. Creating Classes and Methods.

Defining Classes. Creating Instance and Class Variables. Creating Methods. Creating Java Applications. Java Applications and Command-Line Arguments. Creating Methods with the Same Name, Different Arguments. Constructor Methods. Overriding Methods. Finalizer Methods. Summary. Q&A. Quiz. Exercises.

Day 6. Packages, Interfaces, and Other Class Features.

Modifiers. Static Variables and Methods. Final Classes, Methods, and Variables. Abstract Classes and Methods. Packages. Using Packages. Creating Your Own Packages. Interfaces. Creating and Extending Interfaces. Inner Classes. Summary. Q&A. Quiz. Exercises.

Day 7. Threads, Exceptions, and Assertions.

Exceptions. Managing Exceptions. Declaring Methods That Might Throw Exceptions. Creating and Throwing Your Own Exceptions. When and When Not to Use Exceptions. Assertions. Threads. Summary. Q&A. Quiz. Exercises.


Day 8. Data Structures.

Data Structures. Java Data Structures. Generics. Summary. Q&A. Quiz. Exercises.

Day 9. Working with Swing.

Creating an Application. Working with Components. Lists. Summary. Q&A. Quiz. Exercises.

Day 10. Building a Swing Interface.

Swing Features. Summary. Q&A. Quiz. Exercises.

Day 11. Arranging Components on a User Interface.

Basic Interface Layout. Mixing Layout Managers. Card Layout. Grid Bag Layout. Summary. Q&A. Quiz. Exercises.

Day 12. Responding to User Input.

Event Listeners. Working with Methods. Summary. Q&A. Quiz. Exercises.

Day 13. Using Color, Fonts, and Graphics.

The Graphics2D Class. Drawing Text. Color. Drawing Lines and Polygons. Summary. Q&A. Quiz. Exercises.

Day 14. Writing Java Applets and Java Web Start Applications.

How Applets and Applications Are Different. Applet Security Restrictions. Creating Applets. Including an Applet on a Web Page. Java Archives. Passing Parameters to Applets. Suns HTML Converter. Java Web Start. Using Java Web Start. Summary. Q&A. Quiz. Exercises.


Day 15. Working with Input and Output.

Introduction to Streams. Byte Streams. Filtering a Stream. Character Streams. Files and Filename Filters. Summary. Q&A. Quiz. Exercises.

Day 16. Serializing and Examining Objects.

Object Serialization. Inspecting Classes and Methods with Reflection. Remote Method Invocation. Summary. Q&A. Quiz. Exercises.

Day 17. Communicating Across the Internet.

Networking in Java. The java.nio Package. Summary. Q&A. Quiz. Exercises.

Day 18. JavaSound.

JavaSound. Summary. Q&A. Quiz. Exercises.

Day 19. Creating and Using JavaBeans.

Reusable Software Components. Development Tools. Working with JavaBeans. Summary. Q&A. Quiz. Exercises.

Day 20. Reading and Writing Data Using JDBC and XML.

Java Database Connectivity. Using XML. Processing XML with Java. Processing XML with XOM. Summary. Q&A. Quiz. Exercises.

Day 21. Writing Java Servlets and JavaServer Pages.

Using Servlets. Developing Servlets. JavaServer Pages. JSP Standard Tag Library. Summary. Q&A. Quiz. Exercises.


Appendix A. Choosing Java.

Javas Past, Present, and Future. Why Choose Java. Summary.

Appendix B. Using the Java 2 Software Development Kit.

Choosing a Java Development Tool. Configuring the Software Development Kit. Using a Text Editor. Creating a Sample Program. Setting Up the CLASSPATH Variable.

Appendix C. Programming with the Java 2 Software Development Kit.

An Overview of the SDK. The java Interpreter. The javac Compiler. The appletviewer Browser. The javadoc Documentation Tool. The jar Java File Archival Tool. The jdb Debugger. Using System Properties. Summary.

Appendix D. Using the NetBeans Integrated Development Environment.

Choosing a Java Development Tool. Creating a Sample Program.

Appendix E. Writing Java 1.1 Applets.

Java 1.1 Programming. Summary.

Appendix F. Creating Web Services with XML-RPC.

Introduction to XML-RPC. Communicating with XML-RPC. Choosing an XML-RPC Implementation. Using an XML-RPC Web Service. Creating an XML-RPC Web Service. Summary.

Appendix G. Regular Expressions.

Introduction to Pattern Matching. Using Regular Expressions. Patterns. Summary.

Appendix H. Where to Go from Here: Java Resources.

Other Books to Consider. Suns Official Java Site. Other Java Web Sites. Java Newsgroups. Job Opportunities.

Appendix I. This Books Web Site.



The errata for the book is available here in Adobe Portable Document Format (PDF) format. You will need Adobe's Acrobat Reader to view these files. If you do not have the Acrobat Reader installed, you may go to Adobe Systems' web site to download this free reader.

Click on the links below to display the PDF file in a new window. Right-click on the link and select Save As if you want to download it to your hard drive.

Errata for the book - 76 kb -- 0672326280errata.pdf

Submit Errata

More Information

Unlimited one-month access with your purchase
Free Safari Membership