O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Java Garage

Book Description

Enter your Java Garage... where you do your work, not somebody else's. It's where you experiment, escape, tinker, and ultimately succeed.

Java Garage is not your typical Java book. If you're tired of monotonous "feature walks" and dull tutorials, put down those other Java books and pick up Java Garage. Java guru Eben Hewitt takes a fresh look at this popular programming language, providing the insight and guidance to turn the regular programmer into a master. The style is straightforward, thought-provoking and occasionally irreverent.

You'll learn the best ways to program with everything that matters: J2SE 5.0 classes, inheritance, interfaces, type conversions, event handling, exceptions, file I/O, multithreading, inner classes, Swing, JARs, etc. Hewitt provides real working code and instructions for making usable applications that you can exploit and incorporate into your own personal projects with ease. Need answers quickly? The book also includes FAQs for speedy reference and a glossary on steroids that gives you the context, not just the definition.

With Java Garage, you'll learn the best way to create and finish projects with finesse. Think 'zine. Think blog. But, please, do not think of any other Java book you have ever seen.

Table of Contents

  1. Copyright
  2. Acknowledgments
  3. About The Author
  4. What is the Java Garage
  5. Java Buzz
  6. Java Editions and Platforms
  7. Compiling and Running Java Applications
    1. Installing the SDK
    2. Compiling Source Code
    3. Compiling into a Directory Other Than Your Source Directory
    4. Running Programs
    5. Setting the Classpath
    6. Setting the Classpath at Compile Time
    7. Setting the Path
  8. Where to Write Code
    1. Integrated Development Environments
  9. Primitive Types
    1. About Java Primitives
    2. Integer Types
    3. Real Numbers
    4. Characters
    5. Logical Representations
  10. Operators
    1. Operator Precedence
    2. Arithmetic Operators
    3. Incrementing and Decrementing Operators
    4. Relational Operators
    5. Conditional Operators
    6. Ternary Operator
    7. Binary Numbers and Logical Operators
    8. Shift Operators
  11. Control Statements
    1. If/Else
  12. Classes
    1. What Is a Class?
  13. Fridge: Mmm-Mmm Lamb Chops and a Manhattan
  14. Classes Reloaded
    1. Using External Code in Your Programs: import
    2. Constructing Objects
    3. Using Enums
    4. Methods Allow Variable-Length Parameter Lists
    5. Wrapper Classes
    6. Autoboxing
    7. The Class Named Class
  15. Inheritance
    1. PsychoMan PsychoMan PsychoMan
    2. Getting Your Inheritance
  16. Strings
    1. Creating String Objects
    2. String References and Immutability
    3. Doing Stuff with Strings
    4. Character Data Encoding
    5. Useful String Methods
    6. Better Efficiency with StringBuffers
  17. Arrays
    1. Creating Arrays
    2. Using Arrays
    3. Using Stacks
    4. ArrayLists and toArray
  18. Documenting Your Code with Javadoc
    1. Writing Javadoc Comments
    2. Using Javadoc Tags
    3. Using the Javadoc Tool
    4. Changing Javadoc Styles
    5. Generating Javadoc in Eclipse
    6. Generating Javadoc with Ant
  19. Abstract Classes
    1. Dude, Where's My Implementation?
    2. What Is an Abstract Class?
    3. Using Exceptions with Abstract Classes
    4. Using an Abstract Class Polymorphically
  20. Interfaces
    1. Let's Get One Thing Straight
    2. Some Reasons Why Interfaces Are Very Cool
    3. How to Write an Interface
    4. Interfaces Versus Abstract Classes
    5. Constants
    6. Interface Inheritance
    7. Implementing Interfaces
  21. Casting and Type Conversions
    1. Casting
    2. Casting Between Primitives and Wrappers
    3. Casting with Reference Types
  22. Inner Classes
    1. Regular Inner Classes
    2. Using Method Local Inner Classes
    3. Using Anonymous Inner Classes
    4. Static Inner Class
  23. Blog: Inner Classes and Event Handlers
  24. Handling Exceptions
    1. Exceptions
    2. What an Exception Is
    3. Dealing with Exceptions
    4. Built-in Exceptions
    5. Throwing Exceptions
    6. Catching Exceptions
    7. Using Finally
    8. Different Ways of Handling Exceptions
    9. Wrapping an Exception
    10. Toolkit: A Custom Exception
    11. Exceptions and Inheritance
    12. Exception Handling Pretty Good Practices
  25. File Input/Output
    1. Files and Directories
    2. Files
    3. File IO: Reading and Writing Stream Data
    4. Readers and Writers
  26. Fridge: Guacamole
  27. Using Regular Expressions
    1. Purpose of Regex
  28. Creating Guis with Swing
    1. Anatomy of a Swing App: Stuff You Typically Need to Do in Swing
    2. Adding User Controls
    3. User Controls.stepInto()
    4. Spacing and Aligning Components
    5. JEditorPane
    6. JTabbedPane
    7. LayoutManagers Overview
    8. Switch (LAYOUT_MANAGERS) {
    9. Handling Action Events
    10. Creating Menus
    11. A Note About Mixing Swing and AWT Components
  29. Blog Entry: Software Development Black Market
  30. Dates and Times
    1. Dates
    2. Time
  31. Using Timer Tasks
    1. Using TimerTask to Do Stuff at Intervals
    2. Stopping a Timer Thread
    3. Creating a Timer for a Swing GUI Application
  32. Applets
    1. Not-Applet Technologies
    2. Applet Basics
    3. Differences Between Extending JApplet and Applet
    4. Writing an Applet
    5. A Few Applet Tricks
  33. Fridge: Big Daddy Flapjacks
  34. Using System and Runtime
    1. Using the System
    2. Forcing the Garbage Collector to Run
    3. Suggesting Kindly That the Garbage Collector Run
    4. Executing an External Application in Java
    5. Interacting with the User
    6. Toolkit: A Simple Calculator
    7. Determine Number of Processors on the Current Machine
    8. Determine When Your Application Is About to Exit
    9. System Properties
  35. Using the Java Development Tools
    1. Using Common SDK Tools
    2. Discovering Other SDK Tools
  36. FAQ
    1. Setting the CLASSPATH
    2. Setting JAVA_HOME in Windows
    3. Setting the PATH in Windows
    4. Checking Current Java Version
    5. Compiling and Running Programs
    6. Primitive Data Types
    7. Declaring and Initializing Variables
    8. Class Definition
    9. Package Declaration
    10. Import Declaration
    11. Inheritance
    12. Defining and Implementing an Interface
    13. Exceptions
    14. Working with JAR Files
    15. What Is the Java Virtual Machine?
    16. What's In the SDK?
  37. Packaging & Deploying Java Applications
    1. Herding Cats
    2. Creating JAR Files with Eclipse
    3. Creating an Icon for Your Java Application on Windows
  38. Toolkit
    1. A Name Data Class
    2. Credit Card Validator
    3. Application: SimpleTextEditor: Garage Pad
    4. Application: RSS Aggregator
    5. Application: DrawingPad: Garage Doodler
  39. System.Exit…
  40. Java Glossary on Steroids
    1. A
    2. B
    3. C
    4. D
    5. E
    6. F
    7. G
    8. H
    9. I
    10. J
    11. K
    12. L
    13. M
    14. N
    15. O
    16. P
    17. R
    18. S
    19. T
    20. U
    21. V
    22. W
  41. Index