Sams Teach Yourself Java in 24 Hours [NOOK Book]


In just 24 lessons of one hour or less, you can learn how to create Java applications with the free NetBeans visual editing tools.


Using a straightforward, step-by-step approach, popular author Rogers Cadenhead helps you master the skills and technology you need to create desktop and web programs, web services, and even a browser game in Java. Each lesson builds on what you’ve already learned, giving you a solid understanding of the basic ...

See more details below
Sams Teach Yourself Java in 24 Hours

Available on NOOK devices and apps  
  • NOOK Devices
  • Samsung Galaxy Tab 4 NOOK 7.0
  • Samsung Galaxy Tab 4 NOOK 10.1
  • NOOK HD Tablet
  • NOOK HD+ Tablet
  • NOOK eReaders
  • NOOK Color
  • NOOK Tablet
  • Tablet/Phone
  • NOOK for Windows 8 Tablet
  • NOOK for iOS
  • NOOK for Android
  • NOOK Kids for iPad
  • PC/Mac
  • NOOK for Windows 8
  • NOOK for PC
  • NOOK for Mac

Want a NOOK? Explore Now

NOOK Book (eBook)
$17.99 price
(Save 43%)$31.99 List Price


In just 24 lessons of one hour or less, you can learn how to create Java applications with the free NetBeans visual editing tools.


Using a straightforward, step-by-step approach, popular author Rogers Cadenhead helps you master the skills and technology you need to create desktop and web programs, web services, and even a browser game in Java. Each lesson builds on what you’ve already learned, giving you a solid understanding of the basic concepts and terminology.

  • Full-color figures and clear step-by-step instructions visually show you how to program with Java.
  • Quizzes and Exercises at the end of each chapter help you test your knowledge.
  • Notes, Tips, and Cautions provide related information, advice, and warnings.

Learn how to…

  • Set up your Java programming environment
  • Write your first working program in just minutes
  • Control program decisions and behavior
  • Store and work with information
  • Build straightforward user interfaces
  • Create interactive web programs
  • Use threading to build more responsive programs
  • Build a browser-based game from start to finish
  • Read and write files and XML data
  • Master best practices for object-oriented programming
  • Create flexible, interoperable web services with JAX-WS
  • Integrate graphics into your applications
Read More Show Less

Editorial Reviews

Library Journal
Cadenhead's Teach Yourself Java 2 in 24 Hours is a definite beginner's book, a self-tutorial in 24 one-hour chapters. The guides on networking, Threads (the ability of Java to multitask by allowing for multiple processes and actions at the same time), and Swing (a powerful Java interface package for visual design) are for advanced Java programmers but will fit well within most libraries. Copyright 1999 Cahners Business Information.
Cadenhead (a programmer and writer) writes clearly and with great wit, as though he were interacting with a college pal, making this primer on Java 2 an enjoyable read. The goal is to teach programming to anyone with rudimentary computer skills, described as those who can produce a decent resume, or design a web page. The chapters, designed to take an hour each, lead the reader through the basics of programming, the use of graphical user interface, interactive web programs, and creating multimedia programs using color, sound, and animation. Annotation c. Book News, Inc., Portland, OR (
Read More Show Less

Product Details

  • ISBN-13: 9780768689204
  • Publisher: Pearson Education
  • Publication date: 11/8/2009
  • Series: Sams Teach Yourself Series
  • Sold by: Barnes & Noble
  • Format: eBook
  • Edition number: 5
  • Pages: 432
  • File size: 15 MB
  • Note: This product may take a few minutes to download.

Meet the Author

Rogers Cadenhead is a writer, computer programmer, and web developer who has written 21 books on Internet-related topics, including Sams Teach Yourself Java 6 in 21 Days. He maintains the Drudge Retort and other websites that receive more than seven million visits a year. This book’s official website is

Read More Show Less

Read an Excerpt

Chapter 1: Becoming a Programmer

Computer programming is insanely difficult. It requires a four-year degree in computer science, thousands of dollars in computer hardware and software, a keen analytical intellect, the patience of Job, and a strong liking for caffeinated drinks. If you're a programming novice, this is probably what you've heard about computer programming. Aside from the part about caffeine, all of the rumors are greatly exaggerated.

Programming is a lot easier than most people think, although there are several reasons why you might believe otherwise:

  • Computer programmers have been telling people for years that programming is hard. This belief makes it easier for us to find highpaying jobs (or so I've heard) and gives us more leeway to goof off during business hours.
  • Computer programming manuals are often written in a language that only a Scrabble player could appreciate. Strange acronyms like OOP, RAD, COM, and MUMPS are used frequently along with newly invented jargon like instantiation, bytecode, and makefile.
  • Many computer programming languages have been available only with software packages costing $200 or more, which is a lot of cabbage.

Because of the growth of the Internet and other factors, this is a great time to learn programming. Useful programming tools are being made available at low cost (or no cost), often as downloads from World Wide Web sites. Thousands of programmers are distributing their work under "open source" licenses so people can examine how the programs were written, correct errors, and add their own improvements.

The goal of this book is to teach programming to the person who hasnever tried to program before, or the person who tried programming but hated it with an intense passion. The English language will be used as much as possible instead of jargon and obscure acronyms, and all new programming terms will be thoroughly explained as they are introduced.

If I've succeeded, you will finish Sams Teach Yourself Java 2 in 24 Hours with enough programming skill to be a danger to yourself and others. You'll be able to write programs, dive into other programming books with more confidence, and learn programming languages more easily. You also will have developed skills with Java, the most exciting programming language to be introduced in a decade.

The first hour of this book provides some introductory material about programming and gives you instructions on how to set up your computer so you can write Java programs. The following topics will be covered:

  • Choosing which programming language to learn first
  • What Java is
  • Using programs to boss your computer around
  • How programs work
  • How program errors (called hugs) are fixed
  • Acquiring the free Java 2 Software Development Kit
  • Installing the Kit
  • Getting ready to write programs

Choosing a Language

As you might have surmised at this point, computer programming is not as hard as it's cracked up to be. If you're comfortable enough with a computer to create a nice-looking resume, balance a checkbook with software such as Intuit Quicken, or create your own home page on the Web, you can write programs.

The key to learning how to program is to start with the right language. The programming language you choose often depends on the tasks you want the computer to accomplish...

Read More Show Less

Table of Contents


HOUR 1: Becoming a Programmer

Choosing a Language

Telling the Computer What to Do

How Programs Work

How Programs Don’t Work

Choosing a Java Programming Tool

Workshop: Installing a Java Development Tool

HOUR 2: Writing Your First Program

What You Need to Write Programs

Creating the Saluton Program

Beginning the Program

Storing Information in a Variable

Saving the Finished Product

Compiling the Program into a Class File

Fixing Errors

Workshop: Running a Java Program

HOUR 3: Vacationing in Java

First Stop: Sun Microsystems

Going to School with Java

Lunch in JavaWorld

Watching the Skies at NASA

Getting Down to Business

Stopping by Gamelan to Ask for Directions

Workshop: Venturing into Another World

HOUR 4: Understanding How Java Programs Work

Creating an Application

Sending Arguments to Applications

Workshop: Creating an Applet

HOUR 5: Storing and Changing Information in a Program

Statements and Expressions

Assigning Variable Types

Naming Your Variables

Storing Information in Variables

All About Operators

Workshop: Using Expressions

HOUR 6: Using Strings to Communicate

Storing Text in Strings

Displaying Strings in Programs

Using Special Characters in Strings

Pasting Strings Together

Using Other Variables with Strings

Advanced String Handling

Workshop: Presenting Credits

HOUR 7: Using Conditional Tests to Make Decisions

Testing a Condition

if Statements

if-else Statements

switch Statements

The Conditional Operator

Workshop: Watching the Clock

HOUR 8: Repeating an Action with Loops

for Loops

while Loops

do-while Loops

Exiting a Loop

Naming a Loop

Workshop: Testing Your Computer Speed

HOUR 9: Storing Information with Arrays

Creating Arrays

Using Arrays

Multidimensional Arrays

Sorting an Array

Workshop: Array of Prizes, Indeed

HOUR 10: Creating Your First Object

How Object-Oriented Programming Works

Objects in Action

What Objects Are

Understanding Inheritance

Building an Inheritance Hierarchy

Converting Objects and Simple Variables

Workshop: Creating an Object

HOUR 11: Describing What Your Object Is Like

Creating Variables

Creating Class Variables

Creating Behavior with Methods

Putting One Class Inside Another

Using the this Keyword

Workshop: Using Class Methods and Variables

HOUR 12: Making the Most of Existing Objects

The Power of Inheritance

Establishing Inheritance

Working with Existing Objects

Storing Objects of the Same Class in Vectors

Workshop: Creating a Subclass

HOUR 13: Building a Simple User Interface

Swing and the Abstract Windowing Toolkit

Using Components

Workshop: Creating Your Own Component

HOUR 14: Laying Out a User Interface

Using Layout Managers

Workshop: Laying Out an Application

HOUR 15: Responding to User Input

Getting Your Programs to Listen

Setting Up Components to Be Heard

Handling User Events

Workshop: A Little Lotto Madness

HOUR 16: Building a Complex User Interface

Scroll Panes


Change Listeners

Workshop: Using Image Icons and Toolbars

HOUR 17: Creating Interactive Web Programs

Standard Applet Methods

Putting an Applet on a Web Page

Creating an Applet

Sending Parameters from a Web Page

Workshop: Handling Parameters in an Applet

HOUR 18: Handling Errors in a Program


Throwing Exceptions

Workshop: Throwing and Catching


HOUR 19: Creating a Threaded Program


Working with Threads

Starting with init()

Catching Errors as You Set Up URLs

Handling Screen Updates in the paint() Method

Starting the Thread

Handling Mouse Clicks

Workshop: Revolving Links

HOUR 20: Reading and Writing Files


Writing Data to a Stream

Workshop: Reading and Writing Configuration


HOUR 21: Reading and Writing XML Data

Creating an XML File

Reading an XML File

Workshop: Reading RSS Syndication Feeds

HOUR 22: Creating Web Services with JAX-WS

Defining a Service Endpoint Interface

Creating a Service Implementation Bean

Publishing the Web Service

Using Web Service Definition Language


Workshop: Creating a Web Service Client

HOUR 23: Working with Graphics

Using the Font Class

Using the Color Class

Creating Custom Colors

Drawing Lines and Shapes

Workshop: Baking a Pie Graph

HOUR 24: Creating a Browser Game

Designing the Game

Creating a Custom Button in Swing

Creating a Button’s Behavior and Attributes

Clearing Empty Squares with Recursion

Arranging Components as a Grid

Generating Random Numbers

Using the Ternary Operator

Workshop: Publishing an Applet on the Web

APPENDIX A: Using the NetBeans Integrated Development Environment

Installing NetBeans

Creating a New Project

Creating a New Java Class

Running the Application

Fixing Errors

APPENDIX B: Where to Go from Here: Java Resources

Other Books to Consider

Sun’s Official Java Site

Other Java Websites

Internet Relay Chat

Job Opportunities

APPENDIX C: This Book’s Website


Read More Show Less

Customer Reviews

Average Rating 4
( 17 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Terms of Use.
  • - Barnes & reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing all of 16 Customer Reviews
  • Posted July 13, 2010

    I Also Recommend:

    Very good to excellent, but . . .

    I recommend this book. I bought it to supplement a college textbook (the third edition, 2010, of Elizabeth Sugar Boese's inadequate "An Introduction to Programming with Java Applets," which focuses on the wrong things). I was not disappointed -- I soon began using the Sam's book instead of the textbook, because:
    1. Most of it is written clearly and concisely.
    2. It is better organized, because, for one thing, it introduces variables -- the heart and soul of all programming -- earlier than the Boese book does. As a programmer with 25 years' experience, I hereby assure you that variables should always be in Chapter One of all programming books, regardless of programming language, and especially in a language like Java that has so many different types of variables.
    3. It focuses on other things in addition to just GUI programming (the Boese book focuses exclusively on GUI to the detriment of other important concepts).
    4. It provides a link to a website from which one can download a program editor (NetBeans) superior to the one my college asked us to use.
    5. I like the author's sense of humor.
    This book is not without problems:
    1. Chapters 10 through 12 seem to have been written by someone else, someone not interested in explaining anything, someone who seems to have forgotten that one must DEFINE a new word before one can use it in a sentence, and that said definition must be written in clear, understandable language, and must be accompanied by clear examples. Chapters 10 through 12 use one undefined term after another, over and over again, in sentence after sentence, until the whole chapter deteriorates into an incomprehensible mess. Then, surprisingly, subsequent chapters that use the concepts so poorly presented in chapters 10 through 12 are perfectly understandable again. As I said, it is as though chapters 10 through 12 were written by someone else.
    2. There should be a readily-accessible chart, for example in an appendix, that shows all types of variables Java uses (at least, as of the date of the writing of the book), what type of data each can contain, and, most importantly, HOW MUCH data each can contain, that is the number of digits, or minimum and maximum numerical values, each numeric variable can hold. This fundamental, elementary piece of information is critically important, and so should not be hidden in the middle of a chapter!
    Even so, my bottom line remains that, despite its flaws, this book is superior to the others I've seen, even "Java for Dummies," and I recommend it.

    4 out of 4 people found this review helpful.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted March 14, 2001

    The best Java book, bar none

    This is by far the best book I have seen on Java. What others do poorly in 1000 pages, Cadenhead does well in 400. Explanations of OOP and other aspects of Java are clear and concise. Even for those with no programming experience, this is the one. For those with programming experience in low level languages, this is also the one, but you can skip the first 4-5 chapters. Hour 11 clarified OOP for me in 12 pages. An easy read with excellent examples, each followed by line-by-line clear explanations. Covers GUI & Swing in 4 chapters (60 pages of easy and entertaining reading). Has all you will need to start programming in Java.

    2 out of 2 people found this review helpful.

    Was this review helpful? Yes  No   Report this review
  • Posted March 7, 2011

    Source Code Mangled Can't Be Read in Most Examples

    Most examples from Ch1-8 have mangled text in the source code of the examples. Caveat Emptor if you are considering using the Nook edition, you will have to download the source from the author's personal web site, because the source code from the nookBook edition is nearly impossible to get to run. Examples are missing semicolons, missing braces, mismatched single and double quotes, along with text that is mangled. I highly recommend you purchase the text book version. I've emailed the author with no response. This nookBook appears to be missing a quality control step for the source code.

    1 out of 1 people found this review helpful.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted January 23, 2011

    Way overpriced!!!

    Bought a nookcolor so I could start purchasing my books electronically. Am finding that you have to be carefull because the kindle version of some of these epubs are 1/2 the price as they are for nook. Barnes & Noble should start paying attention to this as this will for sure KILL the nook / nookcolor for technology professionals when they can pay 1/2 the price somewhere else for the EXACT same epub.

    Was this review helpful? Yes  No   Report this review
  • Posted December 24, 2010

    GREAT for just learning Java

    First, this book was the first book that actually HELPED me LEARN Java, not like the others I read that just made me curious to the language. The first half or so of the book is oriented around getting the basics of the language down, and defining some of the major parts of Java(classes, methods, etc.), then the rest builds on that, and focuses largely on the GUI(Graphic User Interface-Buttons, textboxes, etc.) aspects of it. I would HIGHLY recommend this book to anyone wanting to get their feet wet in Java.

    Was this review helpful? Yes  No   Report this review
  • Posted August 18, 2010

    Great for beginers

    Great for beginers. Easy to folow. Learn how to use java quickly.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted March 4, 2002

    Begginers Opinion

    I skimmed through 3 Java 2 books before I finnaly spotted this one. I partially understood HTML and could make a few little tricks with Javascript(if copy and paste counts). In the first five chapters I was convinced that learning Java was going to be a breeze, and I was right. This book taught me everything I needed to know with many anologies and real life situations. The question and answer part was very assuring and made it to where you understood the chapter. This is the first, and last, Java book I will ever need to buy. Its almost like learning basic math all over again! It is worth the money and the best begginers book ever. (I'm still a pre-teen and I know Java 2!). Its also one of the cheapest books to come with an intergrated site and step by step instructions on how to download Java software. IF YOU NEED TO LEARN JAVA IN 24 HOURS THIS IS THE BOOK. A PRIMATE COULD LEARN THIS STUFF!

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted April 19, 2001

    Outstanding. Very well written

    The absolute best beginners book in print. I should know. I spent over $120 bucks before I found this book and still couldn't program. Thanks to Mr. Cadenhead for writing a book that everyone can understand.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted March 15, 2001

    Excellent Beginners Book

    The book is well written, the examples are explaned line by line. The examples are 'real world' and useful. There is a web page with all the code for end of chapter assignments that is great. The author is also entertaining, making the reading almost fun.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted March 9, 2001

    Pretty Good For A Beginner

    It's very useful for a new programmer of Java language. It's better than another Idiot's book for Java 2, I learned nothing from that book. But this book give me a brand new look at java.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted July 3, 2011

    No text was provided for this review.

  • Anonymous

    Posted January 15, 2010

    No text was provided for this review.

  • Anonymous

    Posted November 24, 2010

    No text was provided for this review.

  • Anonymous

    Posted January 22, 2010

    No text was provided for this review.

  • Anonymous

    Posted November 8, 2009

    No text was provided for this review.

  • Anonymous

    Posted December 17, 2011

    No text was provided for this review.

Sort by: Showing all of 16 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)