SINGAPORE
Law
Welcome Guest | Login
SEARCH
Advanced
Java for Programmers (Deitel Developer Series) (2ND): Deitel, Paul J./ Deitel, Harvey M.: BOOKS KINOKUNIYA
Book Details
Java for Programmers (Deitel Developer Series) (2ND)
Java for Programmers (Deitel Developer Series) (2ND)
Publisher : Pearson P T R
Published Date : 2011/04
Binding : Paperback
ISBN : 9780132821544

BookWeb Price : S$ 100.92
Kinokuniya Privilege Card member price : S$ 90.83

Availability Status : Available for order from suppliers.
Usually dispatches within 3 weeks.
Language : English

Book Description
Source: ENG
Academic Descriptors: A93603238
Place of Publication: United States
Edition: Subsequent
Continuations: Monograph Series,any number
Textual Format: Computer Applications
Academic Level: Extracurricular
Table of Contents
 
Preface                                            xxi
Before You Begin                                   xxix
    1 Introduction                                 1   (21)
      1.1 Introduction                             2   (1)
      1.2 Introduction to Object Technology        2   (3)
      1.3 Open Source Software                     5   (2)
      1.4 Java and a Typical Java Development      7   (4)
      Environment
      1.5 Test-Driving a Java Application          11  (4)
      1.6 Web 2.0: Going Social                    15  (3)
      1.7 Software Technologies                    18  (2)
      1.8 Keeping Up to Date with Information      20  (1)
      Technologies
      1.9 Wrap-Up                                  21  (1)
    2 Introduction to Java Applications            22  (17)
      2.1 Introduction                             23  (1)
      2.2 Your First Program in Java: Printing     23  (4)
      a Line of Text
      2.3 Modifying Your First Java Program        27  (2)
      2.4 Displaying Text with printf              29  (1)
      2.5 Another Application: Adding Integers     30  (4)
      2.6 Arithmetic                               34  (1)
      2.7 Decision Making: Equality and            35  (3)
      Relational Operators
      2.8 Wrap-Up                                  38  (1)
    3 Introduction to Classes, Objects, Methods    39  (22)
    and Strings
      3.1 Introduction                             40  (1)
      3.2 Declaring a Class with a Method and      40  (4)
      Instantiating an Object of a Class
      3.3 Declaring a Method with a Parameter      44  (3)
      3.4 Instance Variables, set Methods and      47  (5)
      get Methods
      3.5 Primitive Types vs. Reference Types      52  (1)
      3.6 Initializing Objects with Constructors   53  (3)
      3.7 Floating-Point Numbers and Type double   56  (4)
      3.8 Wrap-Up                                  60  (1)
    4 Control Statements: Part 1                   61  (25)
      4.1 Introduction                             62  (1)
      4.2 Control Structures                       62  (2)
      4.3 if Single-Selection Statement            64  (1)
      4.4 if...else Double-Selection Statement     65  (3)
      4.5 while Repetition Statement               68  (2)
      4.6 Counter-Controlled Repetition            70  (3)
      4.7 Sentinel-Controlled Repetition           73  (5)
      4.8 Nested Control Statements                78  (3)
      4.9 Compound Assignment Operators            81  (1)
      4.10 Increment and Decrement Operators       82  (3)
      4.11 Primitive Types                         85  (1)
      4.12 Wrap-Up                                 85  (1)
    5 Control Statements: Part 2                   86  (28)
      5.1 Introduction                             87  (1)
      5.2 Essentials of Counter-Controlled         87  (2)
      Repetition
      5.3 for Repetition Statement                 89  (3)
      5.4 Examples Using the for Statement         92  (4)
      5.5 do...while Repetition Statement          96  (2)
      5.6 switch Multiple-Selection Statement      98  (7)
      5.7 break and continue Statements            105 (2)
      5.8 Logical Operators                        107 (6)
      5.9 Wrap-Up                                  113 (1)
    6 Methods: A Deeper Look                       114 (26)
      6.1 Introduction                             115 (1)
      6.2 Program Modules in Java                  115 (1)
      6.3 static Methods, static Fields and        115 (3)
      Class Math
      6.4 Declaring Methods with Multiple          118 (3)
      Parameters
      6.5 Notes on Declaring and Using Methods     121 (1)
      6.6 Argument Promotion and Casting           122 (1)
      6.7 Java API Packages                        123 (2)
      6.8 Case Study: Random-Number Generation     125 (5)
        6.8.1 Generalized Scaling and Shifting     129 (1)
        of Random Numbers
        6.8.2 Random-Number Repeatability for      129 (1)
        Testing and Debugging
      6.9 Case Study: A Game of Chance;            130 (4)
      Introducing Enumerations
      6.10 Scope of Declarations                   134 (3)
      6.11 Method Overloading                      137 (2)
      6.12 Wrap-Up                                 139 (1)
    7 Arrays and ArrayLists                        140 (47)
      7.1 Introduction                             141 (1)
      7.2 Arrays                                   141 (2)
      7.3 Declaring and Creating Arrays            143 (1)
      7.4 Examples Using Arrays                    144 (9)
      7.5 Case Study: Card Shuffling and           153 (4)
      Dealing Simulation
      7.6 Enhanced for Statement                   157 (2)
      7.7 Passing Arrays to Methods                159 (3)
      7.8 Case Study: Class GradeBook Using an     162 (5)
      Array to Store Grades
      7.9 Multidimensional Arrays                  167 (4)
      7.10 Case Study: Class GradeBook Using a     171 (6)
      Two-Dimensional Array
      7.11 Variable-Length Argument Lists          177 (1)
      7.12 Using Command-Line Arguments            178 (2)
      7.13 Class Arrays                            180 (3)
      7.14 Introduction to Collections and         183 (3)
      Class ArrayList
      7.15 Wrap-Up                                 186 (1)
    8 Classes and Objects: A Deeper Look           187 (37)
      8.1 Introduction                             188 (1)
      8.2 Time Class Case Study                    188 (4)
      8.3 Controlling Access to Members            192 (1)
      8.4 Referring to the Current Object's        193 (2)
      Members with the this Reference
      8.5 Time Class Case Study: Overloaded        195 (6)
      Constructors
      8.6 Default and No-Argument Constructors     201 (1)
      8.7 Notes on Set and Get Methods             202 (1)
      8.8 Composition                              203 (3)
      8.9 Enumerations                             206 (3)
      8.10 Garbage Collection and Method           209 (1)
      finalize
      8.11 static Class Members                    210 (3)
      8.12 static Import                           213 (1)
      8.13 final Instance Variables                214 (1)
      8.14 Time Class Case Study: Creating         215 (6)
      Packages
      8.15 Package Access                          221 (1)
      8.16 Wrap-Up                                 222 (2)
    9 Object-Oriented Programming: Inheritance     224 (30)
      9.1 Introduction                             225 (1)
      9.2 Superclasses and Subclasses              226 (2)
      9.3 protected Members                        228 (1)
      9.4 Relationship between Superclasses and    228 (22)
      Subclasses
        9.4.1 Creating and Using a                 229 (6)
        CommissionEmployee Class
        9.4.2 Creating and Using a                 235 (5)
        BasePlusCommissionEmployee Class
        9.4.3 Creating a                           240 (2)
        CommissionEmployee-BasePlusCommissionEmp
        loyee Inheritance Hierarchy
        9.4.4                                      242 (3)
        CommissionEmployee-BasePlusCommissionEmp
        loyee Inheritance Hierarchy Using
        protected Instance Variables
        9.4.5                                      245 (5)
        CommissionEmployee-BasePlusCommissionEmp
        loyee Inheritance Hierarchy Using
        private Instance Variables
      9.5 Constructors in Subclasses               250 (1)
      9.6 Software Engineering with Inheritance    251 (1)
      9.7 Class Object                             252 (1)
      9.8 Wrap-Up                                  253 (1)
    10 Object-Oriented Programming: Polymorphism   254 (38)
      10.1 Introduction                            255 (2)
      10.2 Polymorphism Examples                   257 (1)
      10.3 Demonstrating Polymorphic Behavior      258 (2)
      10.4 Abstract Classes and Methods            260 (2)
      10.5 Case Study: Payroll System Using        262 (16)
      Polymorphism
        10.5.1 Abstract Superclass Employee        263 (3)
        10.5.2 Concrete Subclass                   266 (2)
        SalariedEmployee
        10.5.3 Concrete Subclass HourlyEmployee    268 (2)
        10.5.4 Concrete Subclass                   270 (1)
        CommissionEmployee
        10.5.5 Indirect Concrete Subclass          271 (2)
        BasePlusCommissionEmployee
        10.5.6 Polymorphic Processing, Operator    273 (4)
        instanceof and Downcasting
        10.5.7 Summary of the Allowed              277 (1)
        Assignments Between Superclass and
        Subclass Variables
      10.6 final Methods and Classes               278 (1)
      10.7 Case Study: Creating and Using          279 (11)
      Interfaces
        10.7.1 Developing a Payable Hierarchy      280 (1)
        10.7.2 Interface Payable                   281 (1)
        10.7.3 Class Invoice                       282 (2)
        10.7.4 Modifying Class Employee to         284 (2)
        Implement Interface Payable
        10.7.5 Modifying Class SalariedEmployee    286 (2)
        for Use in the Payable Hierarchy
        10.7.6 Using Interface Payable to          288 (1)
        Process Invoices and Employees
        Polymorphically
        10.7.7 Common Interfaces of the Java API   289 (1)
      10.8 Wrap-Up                                 290 (2)
    11 Exception Handling: A Deeper Look           292 (26)
      11.1 Introduction                            293 (1)
      11.2 Example: Divide by Zero without         293 (3)
      Exception Handling
      11.3 Example: Handling                       296 (5)
      ArithmeticExceptions and
      InputMismatchExceptions
      11.4 When to Use Exception Handling          301 (1)
      11.5 Java Exception Hierarchy                301 (3)
      11.6 finally Block                           304 (4)
      11.7 Stack Unwinding and Obtaining           308 (3)
      Information from an Exception Object
      11.8 Chained Exceptions                      311 (2)
      11.9 Declaring New Exception Types           313 (1)
      11.10 Preconditions and Postconditions       314 (1)
      11.11 Assertions                             315 (1)
      11.12 (New in Java SE 7) Multi-catch:        316 (1)
      Handling Multiple Exceptions in One catch
      11.13 (New in Java SE 7)                     316 (1)
      try-with-Resources: Automatic Resource
      Deallocation
      11.14 Wrap-Up                                317 (1)
    12 ATM Case Study, Part I: Object-Oriented     318 (41)
    Design with the UML
      12.1 Case Study Introduction                 319 (1)
      12.2 Examining the Requirements Document     319 (8)
      12.3 Identifying the Classes in a            327 (6)
      Requirements Document
      12.4 Identifying Class Attributes            333 (5)
      12.5 Identifying Objects' States and         338 (4)
      Activities
      12.6 Identifying Class Operations            342 (6)
      12.7 Indicating Collaboration Among          348 (7)
      Objects
      12.8 Wrap-Up                                 355 (4)
    13 ATM Case Study Part 2: Implementing an      359 (39)
    Object-Oriented Design
      13.1 Introduction                            360 (1)
      13.2 Starting to Program the Classes of      360 (5)
      the ATM System
      13.3 Incorporating Inheritance and           365 (6)
      Polymorphism into the ATM System
      13.4 ATM Case Study Implementation           371 (24)
        13.4.1 Class ATM                           372 (5)
        13.4.2 Class Screen                        377 (1)
        13.4.3 Class Keypad                        378 (1)
        13.4.4 Class CashDispenser                 379 (1)
        13.4.5 Class DepositSlot                   380 (1)
        13.4.6 Class Account                       381 (2)
        13.4.7 Class BankDatabase                  383 (3)
        13.4.8 Class Transaction                   386 (1)
        13.4.9 Class BalanceInquiry                387 (1)
        13.4.10 Class Withdrawal                   388 (4)
        13.4.11 Class Deposit                      392 (3)
        13.4.12 Class ATMCaseStudy                 395 (1)
      13.5 Wrap-Up                                 395 (3)
    14 GUI Components: Part I                      398 (70)
      14.1 Introduction                            399 (1)
      14.2 Java's New Nimbus Look-and-Feel         400 (1)
      14.3 Simple GUI-Based Input/Output with      401 (3)
      30ptionPane
      14.4 Overview of Swing Components            404 (2)
      14.5 Displaying Text and Images in a         406 (4)
      Window
      14.6 Text Fields and an Introduction to      410 (6)
      Event Handling with Nested Classes
      14.7 Common GUI Event Types and Listener     416 (2)
      Interfaces
      14.8 How Event Handling Works                418 (2)
      14.9 JButton                                 420 (3)
      14.10 Buttons That Maintain State            423 (6)
        14.10.1 JCheckBox                          423 (3)
        14.10.2 JRadioButton                       426 (3)
      14.11 JComboBox; Using an Anonymous Inner    429 (4)
      Class for Event Handling
      14.12 JList                                  433 (2)
      14.13 Multiple-Selection Lists               435 (3)
      14.14 Mouse Event Handling                   438 (5)
      14.15 Adapter Classes                        443 (3)
      14.16 JPanel Subclass for Drawing with       446 (4)
      the Mouse
      14.17 Key Event Handling                     450 (3)
      14.18 Introduction to Layout Managers        453 (9)
        14.18.1 FlowLayout                         454 (3)
        14.18.2 BorderLayout                       457 (3)
        14.18.3 GridLayout                         460 (2)
      14.19 Using Panels to Manage More Complex    462 (2)
      Layouts
      14.20 JTextArea                              464 (3)
      14.21 Wrap-Up                                467 (1)
    15 Graphics and Java 2D                        468 (34)
      15.1 Introduction                            469 (2)
      15.2 Graphics Contexts and Graphics          471 (1)
      Objects
      15.3 Color Control                           472 (7)
      15.4 Manipulating Fonts                      479 (5)
      15.5 Drawing Lines, Rectangles and Ovals     484 (4)
      15.6 Drawing Arcs                            488 (3)
      15.7 Drawing Polygons and Polylines          491 (3)
      15.8 Java 2D API                             494 (7)
      15.9 Wrap-Up                                 501 (1)
    16 Strings, Characters and Regular             502 (37)
    Expressions
      16.1 Introduction                            503 (1)
      16.2 Fundamentals of Characters and          503 (1)
      Strings
      16.3 Class String                            504 (13)
        16.3.1 String Constructors                 504 (1)
        16.3.2 String Methods length, charAt       505 (1)
        and getChars
        16.3.3 Comparing Strings                   506 (5)
        16.3.4 Locating Characters and             511 (2)
        Substrings in Strings
        16.3.5 Extracting Substrings from          513 (1)
        Strings
        16.3.6 Concatenating Strings               514 (1)
        16.3.7 Miscellaneous String Methods        514 (2)
        16.3.8 String Method valueOf               516 (1)
      16.4 Class StringBuilder                     517 (7)
        16.4.1 StringBuilder Constructors          518 (1)
        16.4.2 StringBuilder Methods length,       518 (2)
        capacity, setLength and ensureCapacity
        16.4.3 StringBuilder Methods charAt,       520 (1)
        setCharAt, getChars and reverse
        16.4.4 StringBuilder append Methods        521 (2)
        16.4.5 StringBuilder Insertion and         523 (1)
        Deletion Methods
      16.5 Class Character                         524 (5)
      16.6 Tokenizing Strings                      529 (1)
      16.7 Regular Expressions, Class Pattern      530 (8)
      and Class Matcher
      16.8 Wrap-Up                                 538 (1)
    17 Files, Streams and Object Serialization     539 (39)
      17.1 Introduction                            540 (1)
      17.2 Files and Streams                       540 (2)
      17.3 Class File                              542 (4)
      17.4 Sequential-Access Text Files            546 (16)
        17.4.1 Creating a Sequential-Access        546 (7)
        Text File
        17.4.2 Reading Data from a                 553 (3)
        Sequential-Access Text File
        17.4.3 Case Study: A Credit-Inquiry        556 (5)
        Program
        17.4.4 Updating Sequential-Access Files    561 (1)
      17.5 Object Serialization                    562 (9)
        17.5.1 Creating a Sequential-Access        563 (6)
        File Using Object Serialization
        17.5.2 Reading and Deserializing Data      569 (2)
        from a Sequential-Access File
      17.6 Additional java.io Classes              571 (3)
        17.6.1 Interfaces and Classes for          571 (2)
        Byte-Based Input and Output
        17.6.2 Interfaces and Classes for          573 (1)
        Character-Based Input and Output
      17.7 Opening Files with JFileChooser         574 (3)
      17.8 Wrap-Up                                 577 (1)
    18 Generic Collections                         578 (40)
      18.1 Introduction                            579 (1)
      18.2 Collections Overview                    579 (1)
      18.3 Type-Wrapper Classes for Primitive      580 (1)
      Types
      18.4 Autoboxing and Auto-Unboxing            581 (1)
      18.5 Interface Collection and Class          581 (1)
      Collections
      18.6 Lists                                   582 (8)
        18.6.1 ArrayList and Iterator              583 (2)
        18.6.2 LinkedList                          585 (5)
      18.7 Collections Methods                     590 (12)
        18.7.1 Method sort                         591 (3)
        18.7.2 Method shuffle                      594 (2)
        18.7.3 Methods reverse, fill, copy, max    596 (2)
        and min
        18.7.4 Method binarySearch                 598 (2)
        18.7.5 Methods addAll, frequency and       600 (2)
        disjoint
      18.8 Stack Class of Package java.util        602 (2)
      18.9 Class PriorityQueue and Interface       604 (1)
      Queue
      18.10 Sets                                   605 (3)
      18.11 Maps                                   608 (4)
      18.12 Properties Class                       612 (3)
      18.13 Synchronized Collections               615 (1)
      18.14 Unmodifiable Collections               615 (1)
      18.15 Abstract Implementations               616 (1)
      18.16 Wrap-Up                                616 (2)
    19 Generic Classes and Methods                 618 (28)
      19.1 Introduction                            619 (1)
      19.2 Motivation for Generic Methods          619 (3)
      19.3 Generic Methods: Implementation and     622 (3)
      Compile-Time Translation
      19.4 Additional Compile-Time Translation     625 (3)
      Issues: Methods That Use a Type Parameter
      as the Return Type
      19.5 Overloading Generic Methods             628 (1)
      19.6 Generic Classes                         628 (8)
      19.7 Raw Types                               636 (4)
      19.8 Wildcards in Methods That Accept        640 (4)
      Type Parameters
      19.9 Generics and Inheritance: Notes         644 (1)
      19.10 Wrap-Up                                645 (1)
    20 Applets and Java Web Start                  646 (21)
      20.1 Introduction                            647 (1)
      20.2 Sample Applets Provided with the JDK    648 (4)
      20.3 Simple Java Applet: Drawing a String    652 (4)
        20.3.1 Executing WelcomeApplet in the      654 (2)
        appletviewer
        20.3.2 Executing an Applet in a Web        656 (1)
        Browser
      20.4 Applet Life-Cycle Methods               656 (1)
      20.5 Initialization with Method init         657 (2)
      20.6 Sandbox Security Model                  659 (2)
      20.7 Java Web Start and the Java Network     661 (5)
      Launch Protocol (JNLP)
        20.7.1 Packaging the DrawTest Applet       661 (1)
        for Use with Java Web Start
        20.7.2 JNLP Document for the DrawTest      662 (4)
        Applet
      20.8 Wrap-Up                                 666 (1)
    21 Multimedia: Applets and Applications        667 (27)
      21.1 Introduction                            668 (1)
      21.2 Loading, Displaying and Scaling         669 (6)
      Images
      21.3 Animating a Series of Images            675 (7)
      21.4 Image Maps                              682 (3)
      21.5 Loading and Playing Audio Clips         685 (3)
      21.6 Playing Video and Other Media with      688 (4)
      Java Media Framework
      21.7 Wrap-Up                                 692 (1)
      21.8 Web Resources                           692 (2)
    22 GUI Components: Part 2                      694 (41)
      22.1 Introduction                            695 (1)
      22.2 JSlider                                 695 (4)
      22.3 Windows: Additional Notes               699 (1)
      22.4 Using Menus with Frames                 700 (8)
      22.5 JPopupMenu                              708 (3)
      22.6 Pluggable Look-and-Feel                 711 (5)
      22.7 JDesktopPane and JInternalFrame         716 (4)
      22.8 JTabbedPane                             720 (2)
      22.9 Layout Managers: BoxLayout and          722 (12)
      GridBagLayout
      22.10 Wrap-Up                                734 (1)
    23 Multithreading                              735 (66)
      23.1 Introduction                            736 (2)
      23.2 Thread States: Life Cycle of a Thread   738 (3)
      23.3 Creating and Executing Threads with     741 (3)
      Executor Framework
      23.4 Thread Synchronization                  744 (8)
        23.4.1 Unsynchronized Data Sharing         745 (4)
        23.4.2 Synchronized Data                   749 (3)
        Sharing---Making Operations Atomic
      23.5 Producer/Consumer Relationship          752 (8)
      without Synchronization
      23.6 Producer/Consumer Relationship:         760 (3)
      ArrayBlockingQueue
      23.7 Producer/Consumer Relationship with     763 (6)
      Synchronization
      23.8 Producer/Consumer Relationship:         769 (7)
      Bounded Buffers
      23.9 Producer/Consumer Relationship: The     776 (7)
      Lock and Condition Interfaces
      23.10 Concurrent Collections Overview        783 (2)
      23.11 Multithreading with GUI                785 (14)
        23.11.1 Performing Computations in a       786 (6)
        Worker Thread
        23.11.2 Processing Intermediate Results    792 (7)
        with SwingWorker
      23.12 Interfaces Callable and Future         799 (1)
      23.13 Java SE 7: Fork/Join Framework         799 (1)
      23.14 Wrap-Up                                800 (1)
    24 Networking                                  801 (48)
      24.1 Introduction                            802 (1)
      24.2 Manipulating URLs                       803 (5)
      24.3 Reading a File on a Web Server          808 (3)
      24.4 Establishing a Simple Server Using      811 (2)
      Stream Sockets
      24.5 Establishing a Simple Client Using      813 (1)
      Stream Sockets
      24.6 Client/Server Interaction with          813 (12)
      Stream Socket Connections
      24.7 Datagrams: Connectionless               825 (8)
      Client/Server Interaction
      24.8 Client/Server Tic-Tac-Toe Using a       833 (15)
      Multithreaded Server
      24.9 [Web Bonus] Case Study:                 848 (1)
      DeitelMessenger
      24.10 Wrap-Up                                848 (1)
    25 Accessing Databases with JDBC               849 (58)
      25.1 Introduction                            850 (1)
      25.2 Relational Databases                    851 (1)
      25.3 Relational Database Overview: The       852 (3)
      books Database
      25.4 SQL                                     855 (9)
        25.4.1 Basic SELECT Query                  856 (1)
        25.4.2 WHERE Clause                        857 (2)
        25.4.3 ORDER BY Clause                     859 (1)
        25.4.4 Merging Data from Multiple          860 (2)
        Tables: INNER JOIN
        25.4.5 INSERT Statement                    862 (1)
        25.4.6 UPDATE Statement                    863 (1)
        25.4.7 DELETE Statement                    864 (1)
      25.5 Instructions for Installing MySQL       864 (1)
      and MySQL Connector/J
      25.6 Instructions for Setting Up a MySQL     865 (1)
      User Account
      25.7 Creating Database books in MySQL        866 (1)
      25.8 Manipulating Databases with JDBC        867 (18)
        25.8.1 Connecting to and Querying a        867 (5)
        Database
        25.8.2 Querying the books Database         872 (13)
      25.9 RowSet Interface                        885 (2)
      25.10 Java DB/Apache Derby                   887 (2)
      25.11 PreparedStatements                     889 (15)
      25.12 Stored Procedures                      904 (1)
      25.13 Transaction Processing                 905 (1)
      25.14 Wrap-Up                                905 (1)
      25.15 Web Resources                          906 (1)
    26 JavaServer™ Faces Web Apps: Part 1    907 (35)
      26.1 Introduction                            908 (1)
      26.2 HyperText Transfer Protocol (HTTP)      909 (3)
      Transactions
      26.3 Multitier Application Architecture      912 (1)
      26.4 Your First JSF Web App                  913 (9)
        26.4.1 The Default index.xhtml             914 (2)
        Document: Introducing Facelets
        26.4.2 Examining the WebTimeBean Class     916 (2)
        26.4.3 Building the WebTime JSF Web App    918 (4)
        in NetBeans
      26.5 Model-View-Controller Architecture      922 (1)
      of JSF Apps
      26.6 Common JSF Components                   922 (4)
      26.7 Validation Using JSF Standard           926 (7)
      Validators
      26.8 Session Tracking                        933 (8)
        26.8.1 Cookies                             934 (1)
        26.8.2 Session Tracking with               935 (6)
        @SessionScoped Beans
      26.9 Wrap-Up                                 941 (1)
    27 JavaServer™ Faces Web Apps: Part 2    942 (20)
      27.1 Introduction                            943 (1)
      27.2 Accessing Databases in Web Apps         943 (13)
        27.2.1 Setting Up the Database             945 (3)
        27.2.2 @ManagedBean Class AddressBean      948 (4)
        27.2.3 index.xhtml Facelets Page           952 (2)
        27.2.4 addentry.xhtml Facelets Page        954 (2)
      27.3 Ajax                                    956 (2)
      27.4 Adding Ajax Functionality to the        958 (3)
      Validation App
      27.5 Wrap-Up                                 961 (1)
    28 Web Services                                962 (60)
      28.1 Introduction                            963 (2)
      28.2 Web Service Basics                      965 (1)
      28.3 Simple Object Access Protocol (SOAP)    965 (1)
      28.4 Representational State Transfer         965 (1)
      (REST)
      28.5 JavaScript Object Notation (JSON)       966 (1)
      28.6 Publishing and Consuming SOAP-Based     966 (12)
      Web Services
        28.6.1 Creating a Web Application          966 (1)
        Project and Adding a Web Service Class
        in NetBeans
        28.6.2 Defining the WelcomeSOAP Web        967 (3)
        Service in NetBeans
        28.6.3 Publishing the WelcomeSOAP Web      970 (1)
        Service from NetBeans
        28.6.4 Testing the WelcomeSOAP Web         971 (1)
        Service with GlassFish Application
        Server's Tester Web Page
        28.6.5 Describing a Web Service with       972 (1)
        the Web Service Description Language
        (WSDL)
        28.6.6 Creating a Client to Consume the    973 (2)
        WelcomeSOAP Web Service
        28.6.7 Consuming the WelcomeSOAP Web       975 (3)
        Service
      28.7 Publishing and Consuming REST-Based     978 (5)
      XML Web Services
        28.7.1 Creating a REST-Based XML Web       978 (3)
        Service
        28.7.2 Consuming a REST-Based XML Web      981 (2)
        Service
      28.8 Publishing and Consuming REST-Based     983 (4)
      JSON Web Services
        28.8.1 Creating a REST-Based JSON Web      983 (2)
        Service
        28.8.2 Consuming a REST-Based JSON Web     985 (2)
        Service
      28.9 Session Tracking in a SOAP Web          987 (15)
      Service
        28.9.1 Creating a Blackjack Web Service    988 (3)
        28.9.2 Consuming the Blackjack Web         991 (11)
        Service
      28.10 Consuming a Database-Driven SOAP       1002(7)
      Web Service
        28.10.1 Creating the Reservation           1003(3)
        Database
        28.10.2 Creating a Web Application to      1006(3)
        Interact with the Reservation Service
      28.11 Equation Generator: Returning          1009(11)
      User-Defined Types
        28.11.1 Creating the                       1012(1)
        EquationGeneratorXML Web Service
        28.11.2 Consuming the                      1013(4)
        EquationGeneratorXML Web Service
        28.11.3 Creating the EquationGenerator     1017(1)
        JSON Web Service
        28.11.4 Consuming the EquationGenerator    1017(3)
        JSON Web Service
      28.12 Wrap-Up                                1020(2)
  A Operator Precedence Chart                      1022(2)
  B ASCII Character Set                            1024(1)
  C Keywords and Reserved Words                    1025(1)
  D Primitive Types                                1026(1)
  E Using the Java API Documentation               1027(9)
      E.1 Introduction                             1027(1)
      E.2 Navigating the Java API                  1028(8)
  F Using the Debugger                             1036(16)
      F.1 Introduction                             1037(1)
      F.2 Breakpoints and the run, stop, cont      1037(4)
      and print Commands
      F.3 The print and set Commands               1041(2)
      F.4 Controlling Execution Using the step,    1043(3)
      step up and next Commands
      F.5 The watch Command                        1046(3)
      F.6 The clear Command                        1049(2)
      F.7 Wrap-Up                                  1051(1)
  G Formatted Output                               1052(19)
      G.1 Introduction                             1053(1)
      G.2 Streams                                  1053(1)
      G.3 Formatting Output with printf            1053(1)
      G.4 Printing Integers                        1054(1)
      G.5 Printing Floating-Point Numbers          1055(2)
      G.6 Printing Strings and Characters          1057(1)
      G.7 Printing Dates and Times                 1058(2)
      G.8 Other Conversion Characters              1060(2)
      G.9 Printing with Field Widths and           1062(2)
      Precisions
      G.10 Using Flags in the printf Format        1064(4)
      String
      G.11 Printing with Argument Indices          1068(1)
      G.12 Printing Literals and Escape            1068(1)
      Sequences
      G.13 Formatting Output with Class            1069(1)
      Formatter
      G.14 Wrap-Up                                 1070(1)
  H GroupLayout                                    1071(12)
      H.1 Introduction                             1071(1)
      H.2 GroupLayout Basics                       1071(1)
      H.3 Building a ColorChooser                  1072(10)
      H.4 GroupLayout Web Resources                1082(1)
  I Java Desktop Integration Components            1083(6)
      I.1 Introduction                             1083(1)
      I.2 Splash Screens                           1083(2)
      I.3 Desktop Class                            1085(2)
      I.4 Tray Icons                               1087(2)
  J UML 2: Additional Diagram Types                1089(2)
      J.1 Introduction                             1089(1)
      J.2 Additional Diagram Types                 1089(2)
Index                                              1091
 

The professional programmer's Deitel(R) guide to Java(t) development and the powerful Java platform Written for programmers with a background in high-level language programming, this book applies the Deitel signature live-code approach to teaching programming and explores the Java language and Java APIs in depth. The book presents concepts in the context of fully tested programs, complete with syntax shading, code highlighting, line-by-line code walkthroughs and program outputs. The book features 200+ complete Java programs with 18,000+ lines of proven Java code, and hundreds of tips that will help you build robust applications. Start with an introduction to Java using an early classes and objects approach, then rapidly move on to more advanced topics, including GUI, graphics, exception handling, generics, collections, JDBC(t), web-application development with JavaServer(t) Faces, web services and more. You'll enjoy the Deitels' classic treatment of object-oriented programming and the OOD/UML(R) ATM case study, including a complete Java implementation. When you're finished, you'll have everything you need to build object-oriented Java applications.Practical, example-rich coverage of: * Java SE 7 * Classes, Objects, Encapsulation, Inheritance, Polymorphism, Interfaces * Integrated OOP Case Studies * Industrial-Strength, 95-Page OOD/UML(R) ATM Case Study * JavaServer(t) Faces 2.0, Ajax-Enabled Web Apps, Web Services, Networking * JDBC(t), SQL, Java DB, MySQL(R) * Threads and the Concurrency APIs * I/O, Types, Control Statements, Methods * Arrays, Generics, Collections * Exception Handling, Files * GUI, Graphics, GroupLayout, JDIC * Using the Debugger and the API Docs * Online, Three-Chapter Introduction to Android(t) App Development Visit www.deitel.com For information on Deitel's Dive Into(R) Series instructor-led training courses offered at customer sites worldwide visit www.deitel.com/training or write to deitel@deitel.com Download code examples Check out the growing list of programming Resource Centers Join the Deitel Twitter (@deitel ) and Facebook (www.deitel.com/DeitelFan) communities. To receive updates for this book, subscribe to the free Deitel(R) Buzz Online e-mail newsletter at www.deitel.com/newsletter/subscribe.html Comments from Recent Editions' Reviewers "Introduces good design practices and methodologies right from the beginning.An excellent starting point for developing high-quality robust Java applications." -Simon Ritter, Oracle Corporation "Updated to reflect the state of the art in Java technologies; its deep and crystal clear explanations make it indispensable. Excellent coverage of exception handling. A complete introduction to Java networking. Great coverage of multithreading." -Jose Antonio Gonzalez Seco, Parliament of Andalusia "Of immense value to practitioners of the object-oriented approach. Demystifies inheritance and polymorphism, and illustrates their use in getting elegant, simple and maintainable code. The OO design case study presents the object-oriented approach, from requirements to Java code." -Vinod Varma, Astra Infotech Private Limited " I wish I had this book when I was learning how to program! Good introduction to UML and the software engineering process." -Lance Andersen, Oracle "You'll be well on your way to becoming a great Java programmer with this book. The polymorphism and generic collections chapters are excellent."-Peter Pilgrim, Java Champion, Consultant "The transition from design to implementation is explained powerfully-the reader can easily understand the design issues and how to implement them in Java." -S. Sivakumar, Astra Infotech Private Limited "Gives programmers the benefit of the wisdom derived from many years of software development experience!" -Edward F. Gehringer, North Carolina State University

Contents
Preface xxi Before You Begin xxix Chapter 1Introduction 2 1.2 Introduction to Object Technology 2 1.3 Open Source Software 5 1.4 Java and a Typical Java Development Environment 7 1.5 Test-Driving a Java Application 11 1.6 Web 2.0: Going Social 15 1.7 Software Technologies 18 1.8 Keeping Up to Date with Information Technologies 20 1.9 Wrap-Up 21 Chapter 2: Introduction to Java Applications 22 2.1 Introduction 23 2.2 Your First Program in Java: Printing a Line of Text 23 2.3 Modifying Your First Java Program 27 2.4 Displaying Text with printf 29 2.5 Another Application: Adding Integers 30 2.6 Arithmetic 34 2.7 Decision Making: Equality and Relational Operators 35 2.8 Wrap-Up 38 Chapter 3: Introduction to Classes, Objects, Methods and Strings 39 3.1 Introduction 40 3.2 Declaring a Class with a Method and Instantiating an Object of a Class 40 3.3 Declaring a Method with a Parameter 44 3.4 Instance Variables, set Methods and get Methods 47 3.5 Primitive Types vs. Reference Types 52 3.6 Initializing Objects with Constructors 53 3.7 Floating-Point Numbers and Type double 56 3.8 Wrap-Up 60 Chapter 4: Control Statements: Part 1 61 4.1 Introduction 62 4.2 Control Structures 62 4.3 if Single-Selection Statement 64 4.4 if...else Double-Selection Statement 65 4.5 while Repetition Statement 68 4.6 Counter-Controlled Repetition 70 4.7 Sentinel-Controlled Repetition 73 4.8 Nested Control Statements 78 4.9 Compound Assignment Operators 81 4.10 Increment and Decrement Operators 82 4.11 Primitive Types 85 4.12 Wrap-Up 85 Chapter 5: Control Statements: Part 2 86 5.1 Introduction 87 5.2 Essentials of Counter-Controlled Repetition 87 5.3 for Repetition Statement 89 5.4 Examples Using the for Statement 92 5.5 do...while Repetition Statement 96 5.6 switch Multiple-Selection Statement 98 5.7 break and continue Statements 105 5.8 Logical Operators 107 5.9 Wrap-Up 113 Chapter 6: Methods: A Deeper Look 114 6.1 Introduction 115 6.2 Program Modules in Java 115 6.3 static Methods, static Fields and Class Math 115 6.4 Declaring Methods with Multiple Parameters 118 6.5 Notes on Declaring and Using Methods 121 6.6 Argument Promotion and Casting 122 6.7 Java API Packages 123 6.8 Case Study: Random-Number Generation 125 6.9 Case Study: A Game of Chance; Introducing Enumerations 130 6.10 Scope of Declarations 134 6.11 Method Overloading 137 6.12 Wrap-Up 139 Chapter 7: Arrays and ArrayLists 140 7.1 Introduction 141 7.2 Arrays 141 7.3 Declaring and Creating Arrays 143 7.4 Examples Using Arrays 144 7.5 Case Study: Card Shuffling and Dealing Simulation 153 7.6 Enhanced for Statement 157 7.7 Passing Arrays to Methods 159 7.8 Case Study: Class GradeBook Using an Array to Store Grades 162 7.9 Multidimensional Arrays 167 7.10 Case Study: Class GradeBook Using a Two-Dimensional Array 171 7.11 Variable-Length Argument Lists 177 7.12 Using Command-Line Arguments 178 7.13 Class Arrays 180 7.14 Introduction to Collections and Class ArrayList 183 7.15 Wrap-Up 186 Chapter 8: Classes and Objects: A Deeper Look 187 8.1 Introduction 188 8.2 Time Class Case Study 188 8.3 Controlling Access to Members 192 8.4 Referring to the Current Object's Members with the this Reference 193 8.5 Time Class Case Study: Overloaded Constructors 195 8.6 Default and No-Argument Constructors 201 8.7 Notes on Set and Get Methods 202 8.8 Composition 203 8.9 Enumerations 206 8.10 Garbage Collection and Method finalize 209 8.11 static Class Members 210 8.12 static Import 213 8.13 final Instance Variables 214 8.14 Time Class Case Study: Creating Packages 215 8.15 Package Access 221 8.16 Wrap-Up 222 Chapter 9: Object-Oriented Programming: Inheritance 224 9.1 Introduction 225 9.2 Superclasses and Subclasses 226 9.3 protected Members 228 9.4 Relationship between Superclasses and Subclasses 228 9.5 Constructors in Subclasses 250 9.6 Software Engineering with Inheritance 251 9.7 Class Object 252 9.8 Wrap-Up 253 Chapter 10: Object-Oriented Programming: Polymorphism 254 10.1 Introduction 255 10.2 Polymorphism Examples 257 10.3 Demonstrating Polymorphic Behavior 258 10.4 Abstract Classes and Methods 260 10.5 Case Study: Payroll System Using Polymorphism 262 10.6 final Methods and Classes 278 10.7 Case Study: Creating and Using Interfaces 279 10.8 Wrap-Up 290 Chapter 11: Exception Handling: A Deeper Look 292 11.1 Introduction 293 11.2 Example: Divide by Zero without Exception Handling 293 11.3 Example: Handling ArithmeticExceptions and InputMismatchExceptions 296 11.4 When to Use Exception Handling 301 11.5 Java Exception Hierarchy 301 11.6 finally Block 304 11.7 Stack Unwinding and Obtaining Information from an Exception Object 308 11.8 Chained Exceptions 311 11.9 Declaring New Exception Types 313 11.10 Preconditions and Postconditions 314 11.11 Assertions 315 11.12 (New in Java SE 7) Multi-catch: Handling Multiple Exceptions in One catch 316 11.13 (New in Java SE 7) try-with-Resources: Automatic Resource Deallocation 316 11.14 Wrap-Up 317 Chapter 12: ATM Case Study, Part 1: Object-Oriented Design with the UML 318 12.1 Case Study Introduction 319 12.2 Examining the Requirements Document 319 12.3 Identifying the Classes in a Requirements Document 327 12.4 Identifying Class Attributes 333 12.5 Identifying Objects' States and Activities 338 12.6 Identifying Class Operations 342 12.7 Indicating Collaboration Among Objects 348 12.8 Wrap-Up 355 Chapter 13: ATM Case Study Part 2: Implementing an Object-Oriented Design 359 13.1 Introduction 3 60 13.2 Starting to Program the Classes of the ATM System 360 13.3 Incorporating Inheritance and Polymorphism into the ATM System 365 13.4 ATM Case Study Implementation 371 13.5 Wrap-Up 395 Chapter 14: GUI Components: Part 1 398 14.1 Introduction 399 14.2 Java's New Nimbus Look-and-Feel 400 14.3 Simple GUI-Based Input/Output with JOptionPane 401 14.4 Overview of Swing Components 404 14.5 Displaying Text and Images in a Window 406 14.6 Text Fields and an Introduction to Event Handling with Nested Classes 410 14.7 Common GUI Event Types and Listener Interfaces 416 14.8 How Event Handling Works 418 14.9 JButton 420 14.10 Buttons That Maintain State 423 14.11 JComboBox; Using an Anonymous Inner Class for Event Handling 429 14.12 JList 433 14.13 Multiple-Selection Lists 435 14.14 Mouse Event Handling 438 14.15 Adapter Classes 443 14.16 JPanel Subclass for Drawing with the Mouse 446 14.17 Key Event Handling 450 14.18 Introduction to Layout Managers 453 14.19 Using Panels to Manage More Complex Layouts 462 14.20 JTextArea 464 14.21 Wrap-Up 467 Chapter 15: Graphics and Java 2D 468 15.1 Introduction 469 15.2 Graphics Contexts and Graphics Objects 471 15.3 Color Control 472 15.4 Manipulating Fonts 479 15.5 Drawing Lines, Rectangles and Ovals 484 15.6 Drawing Arcs 488 15.7 Drawing Polygons and Polylines 491 15.8 Java 2D API 494 15.9 Wrap-Up 501 Chapter 16: Strings, Characters and Regular Expressions 502 16.1 Introduction 503 16.2 Fundamentals of Characters and Strings 503 16.3 Class String 504 16.4 Class StringBuilder 517 16.5 Class Character 524 16.6 Tokenizing Strings 529 16.7 Regular Expressions, Class Pattern and Class Matcher 530 16.8 Wrap-Up 538 Chapter 17: Files, Streams and Object Serialization 539 17.1 Introduction 540 17.2 Files and Streams 540 17.3 Class File 542 17.4 Sequential-Access Text Files 546 17.5 Object Serialization 562 17.6 Additional java.io Classes 571 17.7 Opening Files with JFileChooser 574 17.8 Wrap-Up 577 Chapter 18: Generic Collections 578 18.1 Introduction 579 18.2 Collections Overview 579 18.3 Type-Wrapper Classes for Primitive Types 580 18.4 Autoboxing and Auto-Unboxing 581 18.5 Interface Collection and Class Collections 581 18.6 Lists 582 18.7 Collections Methods 590 18.8 Stack Class of Package java.util 602 18.9 Class PriorityQueue and Interface Queue 604 18.10 Sets 605 18.11 Maps 608 18.12 Properties Class 612 18.13 Synchronized Collections 615 18.14 Unmodifiable Collections 615 18.15 Abstract Implementations 616 18.16 Wrap-Up 616 Chapter 19: Generic Classes and Methods 618 19.1 Introduction 619 19.2 Motivation for Generic Methods 619 19.3 Generic Methods: Implementation and Compile-Time Translation 622 19.4 Additional Compile-Time Translation Issues: Methods That Use a Type Parameter as the Return Type 625 19.5 Overloading Generic Methods 628 19.6 Generic Classes 628 19.7 Raw Types 636 19.8 Wildcards in Methods That Accept Type Parameters 640 19.9 Generics and Inheritance: Notes 644 19.10 Wrap-Up 645 Chapter 20: Applets and Java Web Start 646 20.1 Introduction 647 20.2 Sample Applets Provided with the JDK 648 20.3 Simple Java Applet: Drawing a String 652 20.4 Applet Life-Cycle Methods 656 20.5 Initialization with Method init 657 20.6 Sandbox Security Model 659 20.7 Java Web Start and the Java Network Launch Protocol (JNLP) 661 20.8 Wrap-Up 666 Chapter 21: Multimedia: Applets and Applications 667 21.1 Introduction 668 21.2 Loading, Displaying and Scaling Images 669 21.3 Animating a Series of Images 675 21.4 Image Maps 682 21.5 Loading and Playing Audio Clips 685 21.6 Playing Video and Other Media with Java Media Framework 688 21.7 Wrap-Up 692 21.8 Web Resources 692 Chapter 22: GUI Components: Part 2 694 22.1 Introduction 695 22.2 JSlider 695 22.3 Windows: Additional Notes 699 22.4 Using Menus with Frames 700 22.5 JPopupMenu 708 22.6 Pluggable Look-and-Feel 711 22.7 JDesktopPane and JInternalFrame 716 22.8 JTabbedPane 720 22.9 Layout Managers: BoxLayout and GridBagLayout 722 22.10 Wrap-Up 734 Chapter 23: Multithreading 735 23.1 Introduction 736 23.2 Thread States: Life Cycle of a Thread 738 23.3 Creating and Executing Threads with Executor Framework 741 23.4 Thread Synchronization 744 23.5 Producer/Consumer Relationship without Synchronization 752 23.6 Producer/Consumer Relationship: ArrayBlockingQueue 760 23.7 Producer/Consumer Relationship with Synchronization 763 23.8 Producer/Consumer Relationship: Bounded Buffers 769 23.9 Producer/Consumer Relationship: The Lock and Condition Interfaces 776 23.10 Concurrent Collections Overview 783 23.11 Multithreading with GUI 785 23.12 Interfaces Callable and Future 799 23.13 Java SE 7: Fork/Join Framework 799 23.14 Wrap-Up 800 Chapter 24: Networking 801 24.1 Introduction 802 24.2 Manipulating URLs 803 24.3 Reading a File on a Web Server 808 24.4 Establishing a Simple Server Using Stream Sockets 811 24.5 Establishing a Simple Client Using Stream Sockets 813 24.6 Client/Server Interaction with Stream Socket Connections 813 24.7 Datagrams: Connectionless Client/Server Interaction 825 24.8 Client/Server Tic-Tac-Toe Using a Multithreaded Server 833 24.9 [Web Bonus] Case Study: DeitelMessenger 848 24.10 Wrap-Up 848 Chapter 25: Accessing Databases with JDBC 849 25.1 Introduction 850 25.2 Relational Databases 851 25.3 Relational Database Overview: The books Database 852 25.4 SQL 855 25.5 Instructions for Installing MySQL and MySQL Connector/J 864 25.6 Instructions for Setting Up a MySQL User Account 865 25.7 Creating Database books in MySQL 866 25.8 Manipulating Databases with JDBC 867 25.9 RowSet Interface 885 25.10 Java DB/Apache Derby 887 25.11 PreparedStatements 889 25.12 Stored Procedures 904 25.13 Transaction Processing 905 25.14 Wrap-Up 905 25.15 Web Resources 906 Chapter 26: JavaServer(t) Faces Web Apps: Part 1 907 26.1 Introduction 908 26.2 HyperText Transfer Protocol (HTTP) Transactions 909 26.3 Multitier Application Architecture 912 26.4 Your First JSF Web App 913 26.5 Model-View-Controller Architecture of JSF Apps 922 26.6 Common JSF Components 922 26.7 Validation Using JSF Standard Validators 926 26.8 Session Tracking 933 26.9 Wrap-Up 941 Chapter 27: JavaServer(t) Faces Web Apps: Part 2 942 27.1 Introduction 943 27.2 Accessing Databases in Web Apps 943 27.3 Ajax 956 27.4 Adding Ajax Functionality to the Validation App 958 27.5 Wrap-Up 961 Chapter 28: Web Services 962 28.1 Introduction 963 28.2 Web Service Basics 965 28.3 Simple Object Access Protocol (SOAP) 965 28.4 Representational State Transfer (REST) 965 28.5 JavaScript Object Notation (JSON) 966 28.6 Publishing and Consuming SOAP-Based Web Services 966 28.7 Publishing and Consuming REST-Based XML Web Services 978 28.8 Publishing and Consuming REST-Based JSON Web Services 983 28.9 Session Tracking in a SOAP Web Service 987 28.10 Consuming a Database-Driven SOAP Web Service 1002 28.11 Equation Generator: Returning User-Defined Types 1009 28.12 Wrap-Up 1020 Appendix A: Operator Precedence Chart 1022 Appendix B: ASCII Character Set 1024 Appendix C: Keywords and Reserved Words 1025 Appendix D: Primitive Types 1026 Appendix E: Using the Java API Documentation 1027 E.1 Introduction 1027 E.2 Navigating the Java API 1028 Appendix F: Using the Debugger 1036 F.1 Introduction 1037 F.2 Breakpoints and the run, stop, cont and print Commands 1037 F.3 The print and set Commands 1041 F.4 Controlling Execution Using the step, step up and next Commands 1043 F.5 The watch Command 1046 F.6 The clear Command 1049 F.7 Wrap-Up 1051 Appendix G: Formatted Output 1052 G.1 Introduction 1053 G.2 Streams 1053 G.3 Formatting Output with printf 1053 G.4 Printing Integers 1054 G.5 Printing Floating-Point Numbers 1055 G.6 Printing Strings and Characters 1057 G.7 Printing Dates and Times 1058 G.8 Other Conversion Characters 1060 G.9 Printing with Field Widths and Precisions 1062 G.10 Using Flags in the printf Format String 1064 G.11 Printing with Argument Indices 1068 G.12 Printing Literals and Escape Sequences 1068 G.13 Formatting Output with Class Formatter 1069 G.14 Wrap-Up 1070 Appendix H: GroupLayout 1071 H.1 Introduction 1071 H.2 GroupLayout Basics 1071 H.3 Building a ColorChooser 1072 H.4 GroupLayout Web Resources 1082 Appendix I: Java Desktop Integration Components 1083 I.1 Introduction 1083 I.2 Splash Screens 1083 I.3 Desktop Class 1085 I.4 Tray Icons 1087 Appendix J: UML 2: Additional Diagram Types 1089 J.1 Introduction 1089 J.2 Additional Diagram Types 1089 Index 1091