Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
| 1.1 | Basic Elements of a Class Declaration | 3 |
| 1.2 | Static Members in Class Declaration | 8 |
| 1.3 | Defining a Subclass | 11 |
| 1.4 | An Application | 15 |
| 2.1 | Default Values for Fields | 33 |
| 2.2 | Flagging Uninitialized Local Variables of Primitive Data Types | 34 |
| 2.3 | Flagging Uninitialized Local Reference Variables | 35 |
| 3.1 | A JavaBean | 42 |
| 3.2 | Using the this Reference | 46 |
| 3.3 | Namespaces | 49 |
| 3.4 | Using Enums | 55 |
| 3.5 | Declaring Enum Constructors and Members | 56 |
| 3.6 | Declaring Constant-Specific Class Bodies | 60 |
| 3.7 | Using Arrays | 73 |
| 3.8 | Using Anonymous Arrays | 75 |
| 3.9 | Using Multidimensional Arrays | 78 |
| 3.10 | Passing Primitive Values | 83 |
| 3.11 | Passing Reference Values | 84 |
| 3.12 | Passing Arrays | 86 |
| 3.13 | Array Elements as Primitive Data Values | 88 |
| 3.14 | Array Elements as Reference Values | 88 |
| 3.15 | Calling a Varargs Method | 91 |
| 3.16 | Passing Program Arguments | 95 |
| 4.1 | Defining Packages and Using Type Import | 107 |
| 4.2 | Single Static Import | 110 |
| 4.3 | Avoiding the Interface Constant Antipattern | 110 |
| 4.4 | Importing Enum Constants | 111 |
| 4.5 | Shadowing by Importing | 112 |
| 4.6 | Conflict in Importing Static Method with the Same Signature | 113 |
| 4.7 | Importing Nested Static Types | 114 |
| 4.8 | Using Properties | 123 |
| 4.9 | Class Scope | 131 |
| 4.10 | Accessibility Modifiers for Classes and Interfaces | 133 |
| 4.11 | Abstract Classes | 136 |
| 4.12 | Public Accessibility of Members | 139 |
| 4.13 | Accessing Static Members | 147 |
| 4.14 | Accessing Final Members | 149 |
| 4.15 | Synchronized Methods | 151 |
| 5.1 | Operand Evaluation Order | 175 |
| 5.2 | Numeric Promotion in Arithmetic Expressions | 181 |
| 5.3 | Short-Circuit Evaluation Involving Conditional Operators | 198 |
| 6.1 | Fall Through in a switch Statement | 208 |
| 6.2 | Using break in a switch Statement | 210 |
| 6.3 | Nested switch Statement | 211 |
| 6.4 | Enums in switch Statement | 212 |
| 6.5 | The break Statement | 224 |
| 6.6 | Labeled break Statement | 225 |
| 6.7 | The continue Statement | 226 |
| 6.8 | Labeled continue Statement | 227 |
| 6.9 | The return Statement | 228 |
| 6.10 | Method Execution | 236 |
| 6.11 | The try-catch Construct | 247 |
| 6.12 | Exception Propagation | 250 |
| 6.13 | The try-catch-finally Construct | 253 |
| 6.14 | The try-finally Construct | 254 |
| 6.15 | The finally Block and the return Statement | 255 |
| 6.16 | Throwing Exceptions | 256 |
| 6.17 | The throws Clause | 258 |
| 6.18 | Using Assertions | 267 |
| 7.1 | Extending Classes: Inheritance and Accessibility | 285 |
| 7.2 | Overriding, Overloading, and Hiding | 290 |
| 7.3 | Using the super Keyword | 296 |
| 7.4 | Constructor Overloading | 302 |
| 7.5 | The this() Constructor Call | 304 |
| 7.6 | The super() Constructor Call | 305 |
| 7.7 | Interfaces | 311 |
| 7.8 | Variables in Interfaces | 315 |
| 7.9 | Assigning and Passing Reference Values | 320 |
| 7.10 | Choosing the Most Specific Method (Simple Case) | 325 |
| 7.11 | Overloaded Method Resolution | 326 |
| 7.12 | The instanceof and Cast Operators | 329 |
| 7.13 | Using the instanceof Operator | 330 |
| 7.14 | Polymorphism and Dynamic Method Lookup | 341 |
| 7.15 | Implementing Data Structures by Inheritance and Aggregation | 342 |
| 8.1 | Overview of Type Declarations | 353 |
| 8.2 | Static Member Types | 355 |
| 8.3 | Importing Static Member Types | 357 |
| 8.4 | Accessing Members in Enclosing Context (Static Member Classes) | 358 |
| 8.5 | Defining and Instantiating Non-static Member Classes | 360 |
| 8.6 | Special Form of this and new Constructs in Non-static Member Classes | 363 |
| 8.7 | Inheritance Hierarchy and Enclosing Context | 365 |
| 8.8 | Extending Inner Classes | 367 |
| 8.9 | Access in Enclosing Context (Local Classes) | 371 |
| 8.10 | Instantiating Local Classes | 374 |
| 8.11 | Objects of Local Classes as Caches | 376 |
| 8.12 | Defining Anonymous Classes | 378 |
| 8.13 | Accessing Declarations in Enclosing Context (Anonymous Classes) | 381 |
| 9.1 | Garbage Collection Eligibility | 394 |
| 9.2 | Using Finalizers | 397 |
| 9.3 | Invoking Garbage Collection | 400 |
| 9.4 | Initializer Expression Order and Method Calls | 408 |
| 9.5 | Exceptions in Initializer Expressions | 409 |
| 9.6 | Static Initializers and Forward References | 411 |
| 9.7 | Static Initializer Blocks and Exceptions | 412 |
| 9.8 | Instance Initializers and Forward References | 414 |
| 9.9 | Instance Initializer Block in Anonymous Class | 414 |
| 9.10 | Exception Handling in Instance Initializer Blocks | 415 |
| 9.11 | Object State Construction | 417 |
| 9.12 | Initialization under Object State Construction | 419 |
| 10.1 | Methods in the Object class | 426 |
| 10.2 | String Representation of Integers | 435 |
| 10.3 | String Construction and Equality | 441 |
| 10.4 | Reading Characters from a String | 444 |
| 11.1 | Listing Files Under a Directory | 474 |
| 11.2 | Copy a File | 478 |
| 11.3 | Reading and Writing Binary Values | 482 |
| 11.4 | Demonstrating Readers and Writers, and Character Encoding | 498 |
| 11.5 | Changing Passwords | 503 |
| 11.6 | Object Serialization | 513 |
| 11.7 | Non-Serializable Objects | 515 |
| 11.8 | Customized Serialization | 518 |
| 11.9 | Serialization and Inheritance | 520 |
| 12.1 | Understanding Locales | 534 |
| 12.2 | Using the Date class | 536 |
| 12.3 | Using the Calendar Class | 540 |
| 12.4 | Formatting Date/Time | 543 |
| 12.5 | Using the DateFormat class | 544 |
| 12.6 | Using the NumberFormat class | 548 |
| 12.7 | Splitting | 565 |
| 12.8 | String Pattern Matching | 568 |
| 12.9 | Match and Replace | 570 |
| 12.10 | Tokenizing Mode | 573 |
| 12.11 | Parsing Primitive Values and Strings | 576 |
| 12.12 | Using Delimiters and Patterns with a Scanner | 580 |
| 12.13 | Multi-Line Mode | 582 |
| 12.14 | Using the format() Method | 603 |
| 13.1 | Implementing the Runnable Interface | 618 |
| 13.2 | Extending the Thread Class | 621 |
| 13.3 | Mutual Exclusion | 628 |
| 13.4 | Thread States | 637 |
| 13.5 | Waiting and Notifying | 644 |
| 13.6 | Joining of Threads | 648 |
| 13.7 | Thread Termination | 651 |
| 13.8 | Deadlock | 652 |
| 14.1 | A Legacy Class | 662 |
| 14.2 | A Generic Class for Nodes | 664 |
| 14.3 | A Generic Interface and its Implementation | 667 |
| 14.4 | Extending Generic Types | 669 |
| 14.5 | Unchecked Warnings | 671 |
| 14.6 | Illustrating Get and Set Operations Using Parameterized References | 681 |
| 14.7 | Implementing a Simplified Generic Stack | 695 |
| 14.8 | Declaring and Calling Generic Methods | 697 |
| 14.9 | Flexible Comparisons | 710 |
| 14.10 | Using Recursive Bounds | 712 |
| 14.11 | Using the @Override Annotation | 719 |
| 14.12 | Subsignatures | 720 |
| 14.13 | Overriding from Generic Supertype | 720 |
| 14.14 | Missing Supertype Parameterization | 721 |
| 14.15 | Genericity Cannot Be Added to Inherited Methods | 722 |
| 14.16 | Type Parameter in throws Clause | 731 |
| 14.17 | Generic Nested Classes | 732 |
| 15.1 | A Test Case for Version Numbers | 749 |
| 15.2 | Not Overriding the equals() and the hashCode() Methods | 752 |
| 15.3 | Testing the equals() and the hashCode() Methods | 752 |
| 15.4 | Implementing the equals() Method | 756 |
| 15.5 | Implications of Overriding the equals() Method | 759 |
| 15.6 | Implementing the hashCode() Method | 762 |
| 15.7 | Implications of Overriding the hashCode() Method | 765 |
| 15.8 | Implementing the compareTo() Method of the Comparable Interface | 767 |
| 15.9 | Implications of Implementing the compareTo() Method | 769 |
| 15.10 | Natural Ordering and Total Ordering | 773 |
| 15.11 | Using a Comparator for Version Numbers | 774 |
| 15.12 | Using an Iterator | 786 |
| 15.13 | Using a for(:) Loop to Iterate Over a Collection | 789 |
| 15.14 | Converting Collections to Arrays | 790 |
| 15.15 | Traversing Over Sets | 797 |
| 15.16 | Using Sets | 799 |
| 15.17 | Using Navigable Sets | 803 |
| 15.18 | Using Lists | 808 |
| 15.19 | Using Priority Queues | 811 |
| 15.20 | Using Deques as a Stack and as a FIFO Queue | 815 |
| 15.21 | Using Maps | 825 |
| 15.22 | Using Navigable Maps | 831 |