You are previewing SAMS Teach Yourself Programming with Java™ in 24 Hours, FOURTH EDITION.
O'Reilly logo
SAMS Teach Yourself Programming with Java™ in 24 Hours, FOURTH EDITION

Book Description

If you have been wanting to learn Java, check out the newly revised fourth edition of the best-seller Sams Teach Yourself Programming with Java in 24 Hours. This step-by-step tutorial will teach you how to create simple Java programs and applets. Comprised of 24 one-hour lessons, this new edition focuses on key programming concepts and essential Java basics, has been improved by dozens of reader comments, and is reorganized to better cover the latest developments in Java. The book's coverage of core Java programming topics has also been expanded. A great starting point for learning Java, this book is also a great primer to reading sams Teach Yourself Java in 21 Days.

Table of Contents

  1. Copyright
  2. About the Author
  3. Acknowledgments
  4. Reader Acknowledgements
  5. We Want to Hear from You!
  6. Reader Services
  7. Introduction
  8. Getting Started
    1. Becoming a Programmer
      1. Choosing a Language
      2. Telling the Computer What to Do
      3. How Programs Work
      4. How Programs Don't Work
      5. Next Stop: Java
      6. Workshop: Installing a Java Development Tool
      7. Summary
      8. Q&A
      9. Quiz
      10. Activities
    2. Writing Your First Program
      1. What You Need to Write Programs
      2. Creating the Saluton Program
      3. Storing Information in a Variable
      4. Saving the Finished Product
      5. Compiling the Program into a Class File
      6. Fixing Errors
      7. Workshop: Running a Java Program
      8. Summary
      9. Q&A
      10. Quiz
      11. Activities
    3. Vacationing in Java
      1. First Stop: Sun Microsystems
      2. Going to School with Java
      3. Lunch in JavaWorld
      4. Watching the Skies at NASA
      5. Getting Down to Business
      6. Stopping by Gamelan to Ask Directions
      7. Workshop: Venturing into Another World
      8. Summary
      9. Q&A
      10. Quiz
      11. Activities
    4. Understanding How Java Programs Work
      1. Creating an Application
      2. Sending Arguments to Applications
      3. Applet Basics
      4. Sending Parameters to Applets
      5. Workshop: Viewing the Code Used to Run Applets
      6. Summary
      7. Q&A
      8. Quiz
      9. Activities
  9. Learning the Basics of Programming
    1. Storing and Changing Information in a Program
      1. Statements and Expressions
      2. Assigning Variable Types
      3. Naming Your Variables
      4. Storing Information in Variables
      5. Workshop: Using Expressions
      6. All about Operators
      7. Summary
      8. Q&A
      9. Quiz
      10. Activities
    2. Using Strings to Communicate
      1. Storing Text in Strings
      2. Displaying Strings in Programs
      3. Using Special Characters in Strings
      4. Pasting Strings Together
      5. Using Other Variables with Strings
      6. Advanced String Handling
      7. Workshop: Presenting Credits
      8. Summary
      9. Q&A
      10. Quiz
      11. Activities
    3. Using Conditional Tests to Make Decisions
      1. Testing a Condition
      2. if Statements
      3. if-else Statements
      4. switch Statements
      5. The Conditional Operator
      6. Workshop: Watching the Clock
      7. Summary
      8. Q&A
      9. Quiz
      10. Activities
    4. Repeating an Action with Loops
      1. for Loops
      2. while Loops
      3. do-while Loops
      4. Exiting a Loop
      5. Naming a Loop
      6. Workshop: Teaching Your Computer a Lesson
      7. Summary
      8. Q&A
      9. Quiz
      10. Activities
  10. WORKING WITH INFORMATION IN NEW WAYS
    1. Storing Information with Arrays
      1. Creating Arrays
      2. Using Arrays
      3. Multidimensional Arrays
      4. Sorting an Array
      5. Workshop: Array of Prizes, Indeed
      6. Summary
      7. Q&A
      8. Quiz
      9. Activities
    2. Creating Your First Object
      1. How Object-Oriented Programming Works
      2. Objects in Action
      3. What Objects Are
      4. Understanding Inheritance
      5. Building an Inheritance Hierarchy
      6. Converting Objects and Simple Variables
      7. Workshop: Creating an Object
      8. Summary
      9. Q&A
      10. Quiz
      11. Activities
    3. Describing What Your Object Is Like
      1. Creating Variables
      2. Creating Class Variables
      3. Creating Behavior with Methods
      4. Putting One Class inside Another
      5. Using the this Keyword
      6. Workshop: Using Class Methods and Variables
      7. Summary
      8. Q&A
      9. Quiz
      10. Activities
    4. Making the Most of Existing Objects
      1. The Power of Inheritance
      2. Establishing Inheritance
      3. Working with Existing Objects
      4. Storing Objects of the Same Class in Vectors
      5. Workshop: Creating a Subclass
      6. Summary
      7. Q&A
      8. Quiz
      9. Activities
  11. Programming a Graphical User Interface
    1. Building a Simple User Interface
      1. Swing and the Abstract Windowing Toolkit
      2. Using Components
      3. Workshop: Creating Your Own Component
      4. Summary
      5. Q&A
      6. Quiz
      7. Activities
    2. Laying Out a User Interface
      1. Using Layout Managers
      2. Workshop: Laying Out an Application
      3. Summary
      4. Q&A
      5. Quiz
      6. Activities
    3. Responding to User Input
      1. Getting Your Programs to Listen
      2. Setting Up Components to Be Heard
      3. Handling User Events
      4. Workshop: A Little Lotto Madness
      5. Summary
      6. Q&A
      7. Quiz
      8. Activities
    4. Building a Complex User Interface
      1. Scroll Panes
      2. Sliders
      3. Change Listeners
      4. Menus
      5. Workshop: Using Image Icons and Toolbars
      6. Summary
      7. Q&A
      8. Quiz
      9. Activities
  12. Creating Multimedia Programs
    1. Creating Interactive Web Programs
      1. Standard Applet Methods
      2. Putting an Applet on a Web Page
      3. A Sample Applet
      4. The Java Plug-in
      5. Sending Parameters from a Web Page
      6. Receiving Parameters in the Applet
      7. Workshop: Handling Parameters in an Applet
      8. Java Web Start
      9. Using Java Web Start
      10. Summary
      11. Q&A
      12. Quiz
      13. Activities
    2. Handling Errors in a Program
      1. Exceptions
      2. Assertions
      3. Workshop: Throwing and Catching Exceptions
      4. Summary
      5. Q&A
      6. Quiz
      7. Activities
    3. Creating a Threaded Program
      1. Threads
      2. Working with Threads
      3. Starting with init()
      4. Catching Errors as You Set Up URLs
      5. Handling Screen Updates in the paint() Method
      6. Starting the Thread
      7. Handling Mouse Clicks
      8. Workshop: Revolving Links
      9. Summary
      10. Q&A
      11. Quiz
      12. Activities
    4. Reading and Writing Files
      1. Streams
      2. Writing Data to a Stream
      3. Reading and Writing Configuration Properties
      4. Workshop: Writing Bytes to an MP3 File
      5. Summary
      6. Q&A
      7. Quiz
      8. Activities
  13. Creating Multimedia Programs
    1. Reading and Writing XML Data
      1. Creating an XML File
      2. Reading an XML File
      3. Workshop: Reading RSS Syndication Feeds
      4. Summary
      5. Q&A
      6. Quiz
      7. Activities
    2. Using Fonts and Color
      1. Using the Font Class
      2. Using the Color Class
      3. Other Ways to Choose Colors
      4. Workshop: Displaying a Danger Message
      5. Summary
      6. Q&A
      7. Quiz
      8. Activities
    3. Working with Graphics
      1. Using Graphics
      2. Drawing Lines and Shapes
      3. Workshop: Baking a Pie Graph
      4. Summary
      5. Q&A
      6. Quiz
      7. Activities
    4. Creating Animation
      1. Animating a Sequence of Images
      2. Sending Parameters to the Applet
      3. Workshop: Follow the Bouncing Ball
      4. Summary
      5. Q&A
      6. Quiz
      7. Activities
  14. Bonus…
    1. Creating Web Services with XML-RPC
      1. Working with Apache XML-RPC
      2. Creating an XML-RPC Handler
      3. Creating an XML-RPC Server
      4. Creating an XML-RPC Client
      5. Workshop: Enhancing the LottoMadness Application
      6. Summary
      7. Q&A
      8. Quiz
      9. Activities
  15. Appendixes
    1. Using the Java Development Kit
      1. Choosing a Java Development Tool
      2. Configuring the Java Development Kit
      3. Using a Text Editor
      4. Creating a Sample Program
      5. Setting Up the CLASSPATH Variable
    2. Programming with the Java Development Kit
      1. An Overview of the JDK
      2. The java Interpreter
      3. The javac Compiler
      4. The appletviewer Browser
      5. The javadoc Documentation Tool
      6. The jar Java File Archival Tool
      7. The jdb Debugger
      8. Using System Properties
      9. Summary
      10. Q&A
    3. Using the NetBeans Integrated Development Environment
      1. Choosing a Java Development Tool
      2. Creating a Sample Program
    4. Where to Go from Here: Java Resources
      1. Other Books to Consider
      2. Sun's Official Java Site
      3. Other Java Websites
      4. Java Newsgroups
      5. Internet Relay Chat
      6. Job Opportunities
    5. This Book's Website
  16. Sun Microsystems, Inc. Binary Code License Agreement
    1. JAVA™ DEVELOPMENT TOOLS JAXP.JAR AND PARSER.JAR ARCHIVE FILES FROM JAVA API FOR XML PARSING, VERSION 1.0 SUPPLEMENTAL LICENSE TERMS
    2. JAVAHELP™ VERSION 2.0 SUPPLEMENTAL LICENSE TERMS
    3. JAVA™ DEVELOPMENT TOOLS JAVAC COMPILER SUPPLEMENTAL LICENSE TERMS
    4. JAVA™ INTERFACE CLASSES J2EE™ DEPLOYMENT SPECIFICATION INTERFACE CLASSES 1.1 SUPPLEMENTAL LICENSE TERMS
    5. JAVA 2, ENTERPRISE EDITION (J2EE™) MANAGEMENT, VERSION 1.0 JAVA™ INTERFACE CLASSES SUPPLEMENTAL LICENSE TERMS
    6. JAVA™ INTERFACE CLASSES ENTERPRISE JAVABEANS™, VERSION 2.0, INTERFACE CLASSES SUPPLEMENTAL LICENSE TERMS
    7. JAVA™ OPTIONAL PACKAGE JMX™, VERSION 1.2 SUPPLEMENTAL LICENSE TERMS
    8. J2EEeditor.jar SUPPLEMENTAL LICENSE TERMS
    9. resolver-1_1_nb.jar Based on Sun's XML Resolver 1.0 Software License Agreement
  17. What's on the CD-ROM
    1. Windows Installation Instructions
    2. UNIX and UNIX-like Installation Instructions
  18. Index