Sams Teach Yourself Java 6 in 21 Days

( 5 )

Overview

“If you get only one Java book, it should be Sams Teach Yourself Java in 21 Days” –PC Magazine

In just 21 days, you can acquire the knowledge and skills necessary to develop three kinds of programs with Java: applications on your computer, servlets on a web server, and browser-launched Java Web Start applications.

No previous programming experience required. By following the 21 carefully organized lessons in this book, anyone can learn the ...

See more details below
Paperback (Revised)
$33.85
BN.com price
(Save 32%)$49.99 List Price
Other sellers (Paperback)
  • All (14) from $1.99   
  • New (3) from $31.94   
  • Used (11) from $1.99   
Sending request ...

Overview

“If you get only one Java book, it should be Sams Teach Yourself Java in 21 Days” –PC Magazine

In just 21 days, you can acquire the knowledge and skills necessary to develop three kinds of programs with Java: applications on your computer, servlets on a web server, and browser-launched Java Web Start applications.

No previous programming experience required. By following the 21 carefully organized lessons in this book, anyone can learn the basics of Java programming.

Learn at your own pace. You can work through each chapter sequentially to make sure you thoroughly understand all of the concepts and methodologies, or you can focus on specific lessons to learn the techniques that interest you most.

Test your knowledge. Each chapter ends with a Workshop section filled with questions, answers, and exercises for further study. There are even certification practice questions.

“Sams Teach Yourself Java is one of the best introductions to hands-on Java programming. If you buy one book on Java, this is the one to buy!” –Independent Web Review

  • Completely revised, updated, and expanded to cover the latest features of Java 6
  • Learn to develop standalone Java applications, web servlets, JavaServer Pages, and Java Web Start applications
  • Easy-to-understand, practical examples clearly illustrate the fundamentals of Java programming
  • Discover how Swing can help you quickly develop programs with a graphical user interface
  • Find out about JDBC database programming, Internet client/server programming, and XML parsing with the open source XOM class library
  • Covers new features of version 6 such as Java DB, the new relational database that is now a built-in
  • part of Java

Rogers Cadenhead is a web application developer who has written 22 books on Internet-related topics, including Sams Teach Yourself Java 2 in 24 Hours. He maintains this book’s official website at http://www.java21days.com.

Laura Lemay is one of the world’s most popular authors on Web development topics. She is the author of the bestselling Sams Teach Yourself Web Publishing with HTML, as well as Sams Teach Yourself Perl in 21 Days.

CD-ROM includes:

  • Source code for the examples developed in the book
  • Java™ SE Development Kit 6
  • NetBeans™ IDE 5.5
  • Bonus materials

Category: Java Programming

Covers: Java 6 Platform Standard Edition

User Level: Beginning—Intermediate

$44.99 USA / $55.99 CAN / £31.99 Net UK (inc. of VAT)

Read More Show Less

Product Details

  • ISBN-13: 9780672329432
  • Publisher: Sams
  • Publication date: 6/8/2007
  • Series: Sams Teach Yourself Series
  • Edition description: Revised
  • Edition number: 5
  • Pages: 720
  • Sales rank: 1,007,379
  • Product dimensions: 9.48 (w) x 10.92 (h) x 1.62 (d)

Meet the Author

Rogers Cadenhead is a web application developer and author. He has written 22 books on Internet-related topics, including Sams Teach Yourself Java in 24 Hours. He’s also a web publisher whose sites receive more than 24 million visits per year. He maintains this book’s official website at http://www.java21days.com and a personal weblog at http://www.cadenhead.org.

Laura Lemay is a technical writer and author. After spending six years writing software documentation for various computer companies in Silicon Valley, she decided that writing books would be much more fun. In her spare time, she collects computers, email addresses, interesting hair colors, and nonrunning motorcycles. She is also the perpetrator of Sams Teach Yourself Web Publishing with HTML in a Week and Sams Teach Yourself Perl in 21 Days and a personal weblog at http://blog.lauralemay.com.

Read More Show Less

Table of Contents

Introduction 1

How This Book Is Organized... 2

Who Should Read This Book... 4

Conventions Used in This Book... 5

Week I: The Java Language

Day 1: Getting Started with Java 9

The Java Language.... 10

History of the Language... 10

Introduction to Java... 11

Selecting a Development Tool.. 11

Object-Oriented Programming... 12

Objects and Classes.... 14

Attributes and Behavior... 17

Attributes of a Class of Objects.. 17

Behavior of a Class of Objects.. 18

Creating a Class... 19

Running the Program... 21

Organizing Classes and Class Behavior.. 24

Inheritance.... 24

Creating a Class Hierarchy.. 26

Inheritance in Action... 28

Single and Multiple Inheritance.. 29

Interfaces.... 30

Packages.... 30

Summary..... 31

Q&A...... 31

Quiz...... 32

Questions.... 32

Answers.... 32

Certification Practice... 32

Exercises..... 33

Day 2: The ABCs of Programming 35

Statements and Expressions... 36

Variables and Data Types... 36

Creating Variables... 37

Naming Variables... 39

Variable Types.... 39

Assigning Values to Variables.. 41

Constants.... 41

Comments..... 43

Literals..... 44

Number Literals... 45

Boolean Literals... 46

Character Literals... 46

String Literals.... 47

Expressions and Operators... 48

Arithmetic.... 49

More About Assignment.. 51

Incrementing and Decrementing.. 52

Comparisons.... 53

Logical Operators... 54

Operator Precedence... 55

String Arithmetic.... 57

Summary..... 58

Q&A...... 59

Quiz...... 60

Questions.... 60

Answers.... 60

Certification Practice... 60

Exercises..... 61

Day 3: Working with Objects 63

Creating New Objects.... 64

Using new.... 64

What new Does.... 66

A Note on Memory Management. 66

Accessing and Setting Class and Instance Variables 67

Getting Values.... 67

Changing Values... 68

Class Variables.... 69

Calling Methods.... 70

Nesting Method Calls... 72

Class Methods.... 73

References to Objects.... 74

Casting and Converting Objects and Primitive Types 76

Casting Primitive Types... 77

Casting Objects.... 78

Converting Primitive Types to Objects and Vice Versa 80

Comparing Object Values and Classes.. 82

Comparing Objects... 82

Determining the Class of an Object. 84

Summary..... 84

Q&A...... 85

Quiz...... 86

Questions.... 86

Answers.... 86

Certification Practice... 86

Exercises..... 87

Day 4: Lists, Logic, and Loops 89

Arrays..... 90

Declaring Array Variables.. 90

Creating Array Objects... 91

Accessing Array Elements.. 92

Changing Array Elements.. 93

Multidimensional Arrays.. 95

Block Statements.... 96

if Conditionals.... 97

switch Conditionals.... 98

for Loops..... 104

while and do Loops.... 107

while Loops.... 107

do-while Loops... 109

Breaking Out of Loops... 109

Labeled Loops... 110

The Conditional Operator.. 110

Summary..... 112

Q&A..... 112

Quiz...... 112

Questions.... 112

Answers.... 113

Certification Practice... 113

Exercises..... 114

Day 5: Creating Classes and Methods 115

Defining Classes.... 116

Creating Instance and Class Variables.. 116

Defining Instance Variables.. 116

Class Variables... 117

Creating Methods.... 117

Defining Methods... 118

The this Keyword... 120

Variable Scope and Method Definitions. 121

Passing Arguments to Methods.. 122

Class Methods... 123

Creating Java Applications... 124

Helper Classes... 125

Java Applications and Command-line Arguments 126

Passing Arguments to Java Applications. 126

Handling Arguments in Your Java Application 127

Creating Methods with the Same Name, Different Arguments 128

Constructor Methods.... 132

Basic Constructor Methods.. 133

Calling Another Constructor Method. 133

Overloading Constructor Methods. 134

Overriding Methods.... 136

Creating Methods That Override Existing Methods 136

Calling the Original Method.. 137

Overriding Constructors.. 138

Finalizer Methods.... 140

Summary..... 141

Q&A..... 141

Quiz...... 142

Questions.... 142

Answers.... 143

Certification Practice... 143

Exercises..... 144

Day 6: Packages, Interfaces, and Other Class Features 145

Modifiers..... 146

Access Control for Methods and Variables 146

Static Variables and Methods... 152

Final Classes, Methods, and Variables.. 154

Variables.... 155

Methods.... 155

Classes.... 156

Abstract Classes and Methods... 156

Packages..... 157

Using Packages.... 157

Full Package and Class Names.. 158

The import Declaration.. 159

Class Name Conflicts... 160

A Note About Classpath and Where Classes Are Located 161

Creating Your Own Packages... 162

Picking a Package Name.. 162

Creating the Folder Structure.. 162

Adding a Class to a Package.. 163

Packages and Class Access Control. 163

Interfaces..... 164

The Problem of Single Inheritance. 164

Interfaces and Classes... 164

Implementing and Using Interfaces. 165

Implementing Multiple Interfaces. 165

Other Uses of Interfaces.. 166

Creating and Extending Interfaces.. 166

New Interfaces... 166

Methods Inside Interfaces.. 167

Extending Interfaces... 168

Creating an Online Storefront.. 169

Inner Classes..... 175

Summary..... 177

Q&A..... 178

Quiz...... 179

Questions.... 179

Answers.... 179

Certification Practice... 179

Exercises..... 181

Day 7: Exceptions, Assertions, and Threads 183

Exceptions..... 184

Exception Classes... 186

Managing Exceptions.... 187

Exception Consistency Checking. 188

Protecting Code and Catching Exceptions 188

The finally Clause... 190

Declaring Methods That Might Throw Exceptions 193

The throws Clause... 193

Which Exceptions Should You Throw?. 194

Passing On Exceptions... 195

throws and Inheritance... 196

Creating and Throwing Your Own Exceptions. 197

Throwing Exceptions... 197

Creating Your Own Exceptions.. 198

Combining throws, try, and throw. 199

When and When Not to Use Exceptions. 200

When to Use Exceptions.. 200

When Not to Use Exceptions.. 200

Bad Style Using Exceptions.. 201

Assertions..... 202

Threads..... 205

Writing a Threaded Program.. 206

A Threaded Application.. 207

Stopping a Thread... 211

Summary..... 212

Q&A..... 213

Quiz...... 214

Questions.... 214

Answers.... 215

Certification Practice... 215

Exercises..... 216

Week II: The Java Class Library

Day 8: Data Structures 219

Moving Beyond Arrays... 220

Java Structures.... 220

Iterator.... 222

Bit Sets.... 223

Vectors.... 226

Looping Through Data Structures. 229

Stacks.... 232

Map..... 233

Hash Tables.... 235

Generics..... 240

Summary..... 243

Q&A..... 244

Quiz...... 244

Questions.... 244

Answers..... 245

Certification Practice... 245

Exercises..... 246

Day 9: Working with Swing 247

Creating an Application... 248

Creating an Interface... 249

Developing a Framework.. 251

Displaying a Splash Page.. 253

Creating a Component... 253

Adding Components to a Container. 254

Working with Components... 256

Image Icons.... 257

Labels.... 259

Text Fields.... 259

Text Areas.... 260

Scrolling Panes... 262

Check Boxes and Radio Buttons. 263

Combo Boxes.... 266

Lists...... 267

Summary..... 269

Q&A..... 270

Quiz...... 270

Questions.... 270

Answers.... 271

Certification Practice... 271

Exercises..... 272

Day 10: Building a Swing Interface 273

Swing Features.... 274

Setting the Look and Feel.. 274

Standard Dialog Boxes... 277

Using Dialog Boxes... 282

Sliders.... 285

Scroll Panes.... 287

Toolbars.... 288

Progress Bars.... 291

Menus.... 293

Tabbed Panes.... 297

Summary..... 298

Q&A..... 299

Quiz...... 299

Questions.... 299

Answers.... 300

Certification Practice... 300

Exercises..... 301

Day 11: Arranging Components on a User Interface 303

Basic Interface Layout... 304

Laying Out an Interface.. 304

Flow Layout.... 305

Box Layout.... 307

Grid Layout.... 309

Border Layout.... 311

Mixing Layout Managers... 312

Card Layout..... 313

Using Card Layout in an Application. 315

Grid Bag Layout.... 321

Designing the Grid... 323

Creating the Grid... 324

Cell Padding and Insets.. 329

Summary..... 329

Q&A..... 330

Quiz...... 331

Questions.... 331

Answers.... 331

Certification Practice... 331

Exercises..... 332

Day 12: Responding to User Input 333

Event Listeners.... 334

Setting Up Components.. 335

Event-Handling Methods.. 336

Working with Methods... 338

Action Events.... 339

Focus Events.... 340

Item Events.... 342

Key Events.... 344

Mouse Events.... 345

Mouse Motion Events... 345

Window Events... 349

Using Adapter Classes... 350

Summary..... 351

Q&A..... 352

Quiz...... 353

Questions.... 353

Answers.... 353

Certification Practice... 353

Exercises..... 355

Day 13: Using Color, Fonts, and Graphics 357

The Graphics2D Class... 358

The Graphics Coordinate System. 359

Drawing Text..... 360

Improving Fonts and Graphics with Antialiasing 362

Finding Information About a Font. 363

Color..... 365

Using Color Objects... 366

Testing and Setting the Current Colors. 366

Drawing Lines and Polygons... 368

User and Device Coordinate Spaces. 368

Specifying the Rendering Attributes. 368

Creating Objects to Draw.. 371

Drawing Objects... 375

Summary..... 378

Q&A..... 378

Quiz...... 379

Questions.... 379

Answers.... 379

Certification Practice... 379

Exercises..... 380

Day 14: Developing Swing Applications 381

Java Web Start.... 382

Using Java Web Start.... 385

Creating a JNLP File... 386

Supporting Web Start on a Server. 391

Additional JNLP Elements.. 392

Improving Performance with SwingWorker. 394

Summary..... 399

Q&A..... 400

Quiz...... 400

Questions.... 400

Answers.... 401

Certification Practice... 401

Exercises..... 402

Week III: Java Programming

Day 15: Working with Input and Output 405

Introduction to Streams... 406

Using a Stream... 406

Filtering a Stream... 407

Handling Exceptions... 408

Byte Streams..... 408

File Streams.... 408

Filtering a Stream.... 413

Byte Filters.... 413

Character Streams.... 422

Reading Text Files... 422

Writing Text Files... 425

Files and Filename Filters... 426

Summary..... 429

Q&A..... 430

Quiz...... 431

Questions.... 431

Answers.... 431

Certification Practice... 432

Exercises..... 432

Day 16: Serializing and Examining Objects 433

Object Serialization.... 434

Object Output Streams... 435

Object Input Streams... 438

Transient Variables... 441

Checking an Object’s Serialized Fields. 442

Inspecting Classes and Methods with Reflection 443

Inspecting and Creating Classes. 443

Working with Each Part of a Class. 445

Inspecting a Class... 447

Summary..... 449

Q&A..... 449

Quiz...... 450

Questions.... 451

Answers.... 450

Certification Practice... 451

Exercises..... 452

Day 17: Communicating Across the Internet 453

Networking in Java.... 454

Opening a Stream over the Net.. 454

Sockets.... 459

Socket Servers... 463

Testing the Server... 466

The java.nio Package.... 467

Buffers.... 467

Channels.... 471

Summary..... 481

Q&A..... 481

Quiz...... 482

Questions.... 482

Answers.... 482

Certification Practice... 483

Exercises..... 483

Day 18: Accessing Databases with JDBC 485

Java Database Connectivity... 486

Database Drivers... 487

The JDBC-ODBC Bridge... 487

Connecting to an ODBC Data Source. 489

JDBC Drivers.... 502

Summary..... 507

Q&A..... 508

Quiz...... 508

Questions.... 508

Answers.... 509

Certification Practice... 509

Exercises..... 510

Day 19: Reading and Writing RSS Feeds 511

Using XML..... 512

Designing an XML Dialect... 515

Processing XML with Java... 516

Processing XML with XOM... 516

Creating an XML Document.. 518

Modifying an XML Document.. 521

Formatting an XML Document.. 525

Evaluating XOM... 528

Summary..... 530

Q&A..... 531

Quiz...... 531

Questions.... 531

Answers.... 532

Certification Practice... 532

Exercises..... 533

Day 20: XML Web Services 535

Introduction to XML-RPC... 536

Communicating with XML-RPC.. 537

Sending a Request... 538

Responding to a Request.. 539

Choosing an XML-RPC Implementation. 540

Using an XML-RPC Web Service.. 542

Creating an XML-RPC Web Service.. 546

Summary..... 551

Q&A..... 551

Quiz...... 552

Questions.... 552

Answers.... 552

Certification Practice... 552

Exercises..... 553

Day 21: Writing Java Servlets and Java Server Pages 555

Using Servlets.... 556

Developing Servlets.... 559

Using Cookies... 565

Using Sessions... 568

JSP...... 572

Writing a JSP Page... 574

Creating a Web Application.. 581

JSP Standard Tag Library... 587

Summary..... 594

Q&A..... 595

Quiz...... 596

Questions.... 596

Answers.... 596

Certification Practice... 597

Exercises..... 597

Appendixes

Appendix A: Using the Java Development Kit 601

Appendix B: Programming with the Java Development Kit 625

Appendix C: This Book’s Website 649

Index 651

Bonus Material on the Companion CD-ROM

CD1 Choosing Java

CD2 Writing Java Applets

CD3 Regular Expressions

CD4 Where to Go from Here: Java Resources

0672329433, TOC, 5/4/2007

Read More Show Less

Customer Reviews

Average Rating 3
( 5 )
Rating Distribution

5 Star

(0)

4 Star

(2)

3 Star

(1)

2 Star

(1)

1 Star

(1)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com 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 & Noble.com 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 & Noble.com 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 BN.com 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

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com 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 BN.com. 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 5 Customer Reviews
  • Posted February 15, 2010

    I Also Recommend:

    A good way to learn JAVA

    There are a lot of ways to learn a programming language. Teach Yourself JAVA in 21 Days, provides a good way for someone with some basic background in programming to branch out into JAVA and get exposure to a wide range of JAVA capabilities quickly.

    The author uses general information about a topic, followed by code samples with detailed explanations of that code to cover a wide range of JAVA capabilities. Chapter summaries and "test" questions drive home important issues.

    Knowledge of capabilities needs to be reinforced through use of those concepts. Because of the wide range of the capabilities and the book's already nearly 700-page length, the author uses examples that lend themselves to immediate use, and leaves further practice of these capabilities to the reader. A companion disk and a book website, contain; files with code samples from the book, additional JAVA components, answers to Certification Practice questions, and code for exercise solutions. There are also some bonus elements included on the disk (Choosing Java, Writing JAVA Applets, Regular Expressions, and Where to Go from Here).

    I wouldn't suggest this book for a novice to programming, but as a vehicle for someone with some experience programming to expand his or her knowledge into JAVA, I think it is very good.

    There were a few topics that I wish were explained in more detail, but in those rare cases, the author provides resources to find the info.

    All in all a good choice!

    2 out of 2 people found this review helpful.

    Was this review helpful? Yes  No   Report this review
  • Posted August 3, 2009

    Required reading for a solid understanding of the java platform.

    Outstanding work! The truth is that java is not so easy. Java continues to grow and all growth increases complexity. The killer, like in all languages, is the syntax. Once you accept the fact that Java is great and worth the study, then the next step is very easy. Get the right book to begin your adventure. Java 6 is your ticket to ride. My advise is to pace yourself and become familiar with the current lessons and avoid jumping ahead of the book. The learning ladder is the same in all fields. To jump ahead is to dilute and fragment your understanding. OOP is fascinating and while the beginner understands a class, it will take a while for full comprehension to settle in. The scheme is ever so wide with wheels within wheels. Meanwhile, the core aspect of the language can be digested since it is more concrete yet indispensable to embrace the entire concept with "Object" at the very pinnacle of the pyramid. But stay put and allow authors and first rate teachers, Rogers Cadenhead and Laura Lemay take you by the hand to explore this fascinating language and remove the veil away from the mystery.

    2 out of 2 people found this review helpful.

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

    Posted February 11, 2011

    Book, great, shipping, not so great

    I'm going to give this rating 1 start ONLY because I paid extra for expedited shipping, then received an email stating that it wasn't going to ship in the time it was supposed to, yet I received no money back. Get the book, BUT DON'T UPGRADE THE SHIPPING becuase it's a rip off.

    1 out of 3 people found this review helpful.

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

    Posted September 5, 2009

    not for a novice

    I would not recommend this book to a beginning programmer. I think that most people with no prior programming experience will find this book very confusing.

    0 out of 1 people found this review helpful.

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

    Posted February 7, 2010

    No text was provided for this review.

Sort by: Showing all of 5 Customer Reviews

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