Sams Teach Yourself Java 6 in 21 Days

Paperback
from $0.00

Author: Rogers Cadenhead

ISBN-10: 0672329433

ISBN-13: 9780672329432

Category: Programming Languages

“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...

Search in google:

“If you get only one Java book, it should be Sams Teach Yourself Java in 21 Days” –PC MagazineIn 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, andCovers new features of version 6 such as Java DB, the new relational database that is now a built-in part of JavaRogers 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 materialsCategory: Java ProgrammingCovers: Java 6 Platform Standard EditionUser Level: Beginning—Intermediate$44.99 USA / $55.99 CAN / £31.99 Net UK (inc. of VAT)

Introduction 1How This Book Is Organized... 2Who Should Read This Book... 4Conventions Used in This Book... 5Week I: The Java LanguageDay 1: Getting Started with Java 9The Java Language.... 10History of the Language... 10Introduction to Java... 11Selecting a Development Tool.. 11Object-Oriented Programming... 12Objects and Classes.... 14Attributes and Behavior... 17Attributes of a Class of Objects.. 17Behavior of a Class of Objects.. 18Creating a Class... 19Running the Program... 21Organizing Classes and Class Behavior.. 24Inheritance.... 24Creating a Class Hierarchy.. 26Inheritance in Action... 28Single and Multiple Inheritance.. 29Interfaces.... 30Packages.... 30Summary..... 31Q&A...... 31Quiz...... 32Questions.... 32Answers.... 32Certification Practice... 32Exercises..... 33Day 2: The ABCs of Programming 35Statements and Expressions... 36Variables and Data Types... 36Creating Variables... 37Naming Variables... 39Variable Types.... 39Assigning Values to Variables.. 41Constants.... 41Comments..... 43Literals..... 44Number Literals... 45Boolean Literals... 46Character Literals... 46String Literals.... 47Expressions and Operators... 48Arithmetic.... 49More About Assignment.. 51Incrementing and Decrementing.. 52Comparisons.... 53Logical Operators... 54Operator Precedence... 55String Arithmetic.... 57Summary..... 58Q&A...... 59Quiz...... 60Questions.... 60Answers.... 60Certification Practice... 60Exercises..... 61Day 3: Working with Objects 63Creating New Objects.... 64Using new.... 64What new Does.... 66A Note on Memory Management. 66Accessing and Setting Class and Instance Variables 67Getting Values.... 67Changing Values... 68Class Variables.... 69Calling Methods.... 70Nesting Method Calls... 72Class Methods.... 73References to Objects.... 74Casting and Converting Objects and Primitive Types 76Casting Primitive Types... 77Casting Objects.... 78Converting Primitive Types to Objects and Vice Versa 80Comparing Object Values and Classes.. 82Comparing Objects... 82Determining the Class of an Object. 84Summary..... 84Q&A...... 85Quiz...... 86Questions.... 86Answers.... 86Certification Practice... 86Exercises..... 87Day 4: Lists, Logic, and Loops 89Arrays..... 90Declaring Array Variables.. 90Creating Array Objects... 91Accessing Array Elements.. 92Changing Array Elements.. 93Multidimensional Arrays.. 95Block Statements.... 96if Conditionals.... 97switch Conditionals.... 98for Loops..... 104while and do Loops.... 107while Loops.... 107do-while Loops... 109Breaking Out of Loops... 109Labeled Loops... 110The Conditional Operator.. 110Summary..... 112Q&A..... 112Quiz...... 112Questions.... 112Answers.... 113Certification Practice... 113Exercises..... 114Day 5: Creating Classes and Methods 115Defining Classes.... 116Creating Instance and Class Variables.. 116Defining Instance Variables.. 116Class Variables... 117Creating Methods.... 117Defining Methods... 118The this Keyword... 120Variable Scope and Method Definitions. 121Passing Arguments to Methods.. 122Class Methods... 123Creating Java Applications... 124Helper Classes... 125Java Applications and Command-line Arguments 126Passing Arguments to Java Applications. 126Handling Arguments in Your Java Application 127Creating Methods with the Same Name, Different Arguments 128Constructor Methods.... 132Basic Constructor Methods.. 133Calling Another Constructor Method. 133Overloading Constructor Methods. 134Overriding Methods.... 136Creating Methods That Override Existing Methods 136Calling the Original Method.. 137Overriding Constructors.. 138Finalizer Methods.... 140Summary..... 141Q&A..... 141Quiz...... 142Questions.... 142Answers.... 143Certification Practice... 143Exercises..... 144Day 6: Packages, Interfaces, and Other Class Features 145Modifiers..... 146Access Control for Methods and Variables 146Static Variables and Methods... 152Final Classes, Methods, and Variables.. 154Variables.... 155Methods.... 155Classes.... 156Abstract Classes and Methods... 156Packages..... 157Using Packages.... 157Full Package and Class Names.. 158The import Declaration.. 159Class Name Conflicts... 160A Note About Classpath and Where Classes Are Located 161Creating Your Own Packages... 162Picking a Package Name.. 162Creating the Folder Structure.. 162Adding a Class to a Package.. 163Packages and Class Access Control. 163Interfaces..... 164The Problem of Single Inheritance. 164Interfaces and Classes... 164Implementing and Using Interfaces. 165Implementing Multiple Interfaces. 165Other Uses of Interfaces.. 166Creating and Extending Interfaces.. 166New Interfaces... 166Methods Inside Interfaces.. 167Extending Interfaces... 168Creating an Online Storefront.. 169Inner Classes..... 175Summary..... 177Q&A..... 178Quiz...... 179Questions.... 179Answers.... 179Certification Practice... 179Exercises..... 181Day 7: Exceptions, Assertions, and Threads 183Exceptions..... 184Exception Classes... 186Managing Exceptions.... 187Exception Consistency Checking. 188Protecting Code and Catching Exceptions 188The finally Clause... 190Declaring Methods That Might Throw Exceptions 193The throws Clause... 193Which Exceptions Should You Throw?. 194Passing On Exceptions... 195throws and Inheritance... 196Creating and Throwing Your Own Exceptions. 197Throwing Exceptions... 197Creating Your Own Exceptions.. 198Combining throws, try, and throw. 199When and When Not to Use Exceptions. 200When to Use Exceptions.. 200When Not to Use Exceptions.. 200Bad Style Using Exceptions.. 201Assertions..... 202Threads..... 205Writing a Threaded Program.. 206A Threaded Application.. 207Stopping a Thread... 211Summary..... 212Q&A..... 213Quiz...... 214Questions.... 214Answers.... 215Certification Practice... 215Exercises..... 216Week II: The Java Class LibraryDay 8: Data Structures 219Moving Beyond Arrays... 220Java Structures.... 220Iterator.... 222Bit Sets.... 223Vectors.... 226Looping Through Data Structures. 229Stacks.... 232Map..... 233Hash Tables.... 235Generics..... 240Summary..... 243Q&A..... 244Quiz...... 244Questions.... 244Answers..... 245Certification Practice... 245Exercises..... 246Day 9: Working with Swing 247Creating an Application... 248Creating an Interface... 249Developing a Framework.. 251Displaying a Splash Page.. 253Creating a Component... 253Adding Components to a Container. 254Working with Components... 256Image Icons.... 257Labels.... 259Text Fields.... 259Text Areas.... 260Scrolling Panes... 262Check Boxes and Radio Buttons. 263Combo Boxes.... 266Lists...... 267Summary..... 269Q&A..... 270Quiz...... 270Questions.... 270Answers.... 271Certification Practice... 271Exercises..... 272Day 10: Building a Swing Interface 273Swing Features.... 274Setting the Look and Feel.. 274Standard Dialog Boxes... 277Using Dialog Boxes... 282Sliders.... 285Scroll Panes.... 287Toolbars.... 288Progress Bars.... 291Menus.... 293Tabbed Panes.... 297Summary..... 298Q&A..... 299Quiz...... 299Questions.... 299Answers.... 300Certification Practice... 300Exercises..... 301Day 11: Arranging Components on a User Interface 303Basic Interface Layout... 304Laying Out an Interface.. 304Flow Layout.... 305Box Layout.... 307Grid Layout.... 309Border Layout.... 311Mixing Layout Managers... 312Card Layout..... 313Using Card Layout in an Application. 315Grid Bag Layout.... 321Designing the Grid... 323Creating the Grid... 324Cell Padding and Insets.. 329Summary..... 329Q&A..... 330Quiz...... 331Questions.... 331Answers.... 331Certification Practice... 331Exercises..... 332Day 12: Responding to User Input 333Event Listeners.... 334Setting Up Components.. 335Event-Handling Methods.. 336Working with Methods... 338Action Events.... 339Focus Events.... 340Item Events.... 342Key Events.... 344Mouse Events.... 345Mouse Motion Events... 345Window Events... 349Using Adapter Classes... 350Summary..... 351Q&A..... 352Quiz...... 353Questions.... 353Answers.... 353Certification Practice... 353Exercises..... 355Day 13: Using Color, Fonts, and Graphics 357The Graphics2D Class... 358The Graphics Coordinate System. 359Drawing Text..... 360Improving Fonts and Graphics with Antialiasing 362Finding Information About a Font. 363Color..... 365Using Color Objects... 366Testing and Setting the Current Colors. 366Drawing Lines and Polygons... 368User and Device Coordinate Spaces. 368Specifying the Rendering Attributes. 368Creating Objects to Draw.. 371Drawing Objects... 375Summary..... 378Q&A..... 378Quiz...... 379Questions.... 379Answers.... 379Certification Practice... 379Exercises..... 380Day 14: Developing Swing Applications 381Java Web Start.... 382Using Java Web Start.... 385Creating a JNLP File... 386Supporting Web Start on a Server. 391Additional JNLP Elements.. 392Improving Performance with SwingWorker. 394Summary..... 399Q&A..... 400Quiz...... 400Questions.... 400Answers.... 401Certification Practice... 401Exercises..... 402Week III: Java ProgrammingDay 15: Working with Input and Output 405Introduction to Streams... 406Using a Stream... 406Filtering a Stream... 407Handling Exceptions... 408Byte Streams..... 408File Streams.... 408Filtering a Stream.... 413Byte Filters.... 413Character Streams.... 422Reading Text Files... 422Writing Text Files... 425Files and Filename Filters... 426Summary..... 429Q&A..... 430Quiz...... 431Questions.... 431Answers.... 431Certification Practice... 432Exercises..... 432Day 16: Serializing and Examining Objects 433Object Serialization.... 434Object Output Streams... 435Object Input Streams... 438Transient Variables... 441Checking an Object’s Serialized Fields. 442Inspecting Classes and Methods with Reflection 443Inspecting and Creating Classes. 443Working with Each Part of a Class. 445Inspecting a Class... 447Summary..... 449Q&A..... 449Quiz...... 450Questions.... 451Answers.... 450Certification Practice... 451Exercises..... 452Day 17: Communicating Across the Internet 453Networking in Java.... 454Opening a Stream over the Net.. 454Sockets.... 459Socket Servers... 463Testing the Server... 466The java.nio Package.... 467Buffers.... 467Channels.... 471Summary..... 481Q&A..... 481Quiz...... 482Questions.... 482Answers.... 482Certification Practice... 483Exercises..... 483Day 18: Accessing Databases with JDBC 485Java Database Connectivity... 486Database Drivers... 487The JDBC-ODBC Bridge... 487Connecting to an ODBC Data Source. 489JDBC Drivers.... 502Summary..... 507Q&A..... 508Quiz...... 508Questions.... 508Answers.... 509Certification Practice... 509Exercises..... 510Day 19: Reading and Writing RSS Feeds 511UsingDesigning anProcessingProcessingCreating anModifying anFormatting anEvaluating XOM... 528Summary..... 530Q&A..... 531Quiz...... 531Questions.... 531Answers.... 532Certification Practice... 532Exercises..... 533Day 20:Introduction toCommunicating withSending a Request... 538Responding to a Request.. 539Choosing anUsing anCreating anSummary..... 551Q&A..... 551Quiz...... 552Questions.... 552Answers.... 552Certification Practice... 552Exercises..... 553Day 21: Writing Java Servlets and Java Server Pages 555Using Servlets.... 556Developing Servlets.... 559Using Cookies... 565Using Sessions... 568JSP...... 572Writing a JSP Page... 574Creating a Web Application.. 581JSP Standard Tag Library... 587Summary..... 594Q&A..... 595Quiz...... 596Questions.... 596Answers.... 596Certification Practice... 597Exercises..... 597AppendixesAppendix A: Using the Java Development Kit 601Appendix B: Programming with the Java Development Kit 625Appendix C: This Book’s Website 649Index 651Bonus Material on the Companion CD-ROMCD1 Choosing JavaCD2 Writing Java AppletsCD3 Regular ExpressionsCD4 Where to Go from Here: Java Resources0672329433, TOC, 5/4/2007