Cover image for Java 7 Pocket Guide, 2nd Edition

Book description

When you need quick answers for developing or debugging Java programs, this pocket guide provides a handy reference to the standard features of the Java programming language and its platform. You’ll find helpful programming examples, tables, figures, and lists, as well as supplemental information about topics including the Java Scripting API, third-party tools, and the basics of the Unified Modeling Language (UML).

Table of Contents

  1. Dedication
  2. Special Upgrade Offer
  3. Preface
    1. Book Structure
    2. Conventions Used in This Book
    3. Authors
    4. Safari® Books Online
    5. How to Contact Us
    6. Second Edition Acknowledgments
  4. I. Language
    1. 1. Naming Conventions
      1. Class Names
      2. Interface Names
      3. Method Names
      4. Instance and Static Variable Names
      5. Parameter and Local Variable Names
      6. Generic Type Parameter Names
      7. Constant Names
      8. Enumeration Names
      9. Package Names
      10. Acronyms
    2. 2. Lexical Elements
      1. Unicode and ASCII
        1. Printable ASCII Characters
        2. Nonprintable ASCII Characters
      2. Comments
      3. Keywords
      4. Identifiers
      5. Separators
      6. Operators
      7. Literals
        1. Boolean Literals
        2. Character Literals
        3. Integer Literals
        4. Floating-Point Literals
        5. String Literals
        6. Null Literals
      8. Escape Sequences
      9. Unicode Currency Symbols
    3. 3. Fundamental Types
      1. Primitive Types
      2. Literals for Primitive Types
      3. Floating-Point Entities
        1. Operations Involving Special Entities
      4. Numeric Promotion of Primitive Types
        1. Unary Numeric Promotion
        2. Binary Numeric Promotion
        3. Special Cases for Conditional Operators
      5. Wrapper Classes
      6. Autoboxing and Unboxing
        1. Autoboxing
        2. Unboxing
    4. 4. Reference Types
      1. Comparing Reference Types to Primitive Types
      2. Default Values
        1. Instance and Local Variable Objects
        2. Arrays
      3. Conversion of Reference Types
        1. Widening Conversions
        2. Narrowing Conversions
      4. Converting Between Primitives and Reference Types
      5. Passing Reference Types into Methods
      6. Comparing Reference Types
        1. Using the Equality Operators
        2. Using the equals() Method
        3. Comparing Strings
        4. Comparing Enumerations
      7. Copying Reference Types
        1. Copying a Reference to an Object
        2. Cloning Objects
          1. Shallow and deep cloning
      8. Memory Allocation and Garbage Collection of Reference Types
    5. 5. Object-Oriented Programming
      1. Classes and Objects
        1. Class Syntax
        2. Instantiating a Class (Creating an Object)
        3. Data Members and Methods
        4. Accessing Data Members and Methods in Objects
        5. Overloading
        6. Overriding
        7. Constructors
        8. Superclasses and Subclasses
        9. The this Keyword
      2. Variable-Length Argument Lists
      3. Abstract Classes and Abstract Methods
        1. Abstract Classes
        2. Abstract Methods
      4. Static Data Members, Static Methods, Static Constants, and Static Initializers
        1. Static Data Members
        2. Static Methods
        3. Static Constants
        4. Static Initializers
      5. Interfaces
      6. Enumerations
      7. Annotation Types
        1. Built-in Annotations
        2. Developer-Defined Annotations
    6. 6. Statements and Blocks
      1. Expression Statements
      2. Empty Statement
      3. Blocks
      4. Conditional Statements
        1. The if Statement
        2. The if else Statement
        3. The if else if Statement
        4. The switch Statement
      5. Iteration Statements
        1. The for Loop
        2. The Enhanced for Loop
        3. The while Loop
        4. The do while Loop
      6. Transfer of Control
        1. The break Statement
        2. The continue Statement
        3. The return Statement
      7. Synchronized Statement
      8. Assert Statement
      9. Exception Handling Statements
    7. 7. Exception Handling
      1. The Exception Hierarchy
      2. Checked/Unchecked Exceptions and Errors
        1. Checked Exceptions
        2. Unchecked Exceptions
        3. Errors
      3. Common Checked/Unchecked Exceptions and Errors
        1. Common Checked Exceptions
        2. Common Unchecked Exceptions
        3. Common Errors
      4. Exception Handling Keywords
        1. The throw Keyword
        2. The try/catch/finally Keywords
        3. The try-catch Statement
        4. The try-finally Statement
        5. The try-catch-finally Statement
        6. The try-with-resources Statement
        7. The multi-catch Clause
      5. The Exception Handling Process
      6. Defining Your Own Exception Class
      7. Printing Information About Exceptions
        1. The getMessage() Method
        2. The toString() Method
        3. The printStackTrace() Method
    8. 8. Java Modifiers
      1. Access Modifiers
      2. Other (Nonaccess) Modifiers
  5. II. Platform
    1. 9. Java Platform, SE
      1. Common Java SE API Libraries
        1. Language and Utility Libraries
        2. Base Libraries
        3. Integration Libraries
        4. User Interface Libraries: Miscellaneous
        5. User Interface Libraries: Abstract Window Toolkit (AWT) API
        6. User Interface Libraries: Swing API
        7. Remote Method Invocation (RMI) and CORBA Libraries
        8. Security Libraries
        9. Extensible Markup Language (XML) Libraries
    2. 10. Development Basics
      1. Java Runtime Environment
      2. Java Development Kit
      3. Java Program Structure
      4. Command-Line Tools
        1. Java Compiler
        2. Java Interpreter
        3. Java Program Packager
        4. JAR File Execution
        5. Java Documenter
      5. Classpath
    3. 11. Memory Management
      1. Garbage Collectors
        1. Serial Collector
        2. Parallel Collector
        3. Parallel Compacting Collector
        4. Concurrent Mark-Sweep (CMS) Collector
        5. Garbage-First (G1) Collector
      2. Memory Management Tools
      3. Command-Line Options
      4. Resizing the JVM Heap
      5. Interfacing with the GC
        1. Explicit Garbage Collection
        2. Finalization
    4. 12. Basic Input and Output
      1. Standard Streams in, out, and err
      2. Class Hierarchy for Basic Input and Output
      3. File Reading and Writing
        1. Reading Character Data from a File
        2. Reading Binary Data from a File
        3. Writing Character Data to a File
        4. Writing Binary Data to a File
      4. Socket Reading and Writing
        1. Reading Character Data from a Socket
        2. Reading Binary Data from a Socket
        3. Writing Character Data to a Socket
        4. Writing Binary Data to a Socket
      5. Serialization
        1. Serialize
        2. Deserialize
      6. Zipping and Unzipping Files
        1. Compressing and Uncompressing GZIP Files
      7. File and Directory Handling
        1. Commonly Used Methods in the File Class
        2. Accessing Existing Files
        3. Seeking in Files
    5. 13. NIO 2.0 Quicklook
      1. The Path Interface
      2. The Files Class
      3. Additional Features
    6. 14. Concurrency
      1. Creating Threads
        1. Extending the Thread Class
        2. Implementing the Runnable Interface
      2. Thread States
      3. Thread Priorities
      4. Common Methods
      5. Synchronization
      6. Concurrent Utilities
        1. Executors
        2. Concurrent Collections
        3. Synchronizers
        4. Timing Utility
    7. 15. Java Collections Framework
      1. The Collection Interface
      2. Implementations
      3. Collection Framework Methods
      4. Collections Class Algorithms
      5. Algorithm Efficiencies
      6. Comparator Interface
    8. 16. Generics Framework
      1. Generic Classes and Interfaces
      2. Constructors with Generics
      3. Substitution Principle
      4. Type Parameters, Wildcards, and Bounds
      5. The Get and Put Principle
      6. Generic Specialization
      7. Generic Methods in Raw Types
    9. 17. The Java Scripting API
      1. Scripting Languages
      2. Script Engine Implementations
        1. Embedding Scripts into Java
        2. Invoking Methods of Scripting Languages
        3. Accessing and Controlling Java Resources from Scripts
      3. Setting Up Scripting Languages and Engines
        1. Scripting Language Setup
        2. Scripting Engine Setup
        3. Scripting Engine Validation
  6. III. Appendixes
    1. A. Third-Party Tools
      1. Development, CM, and Test Tools
      2. Libraries
      3. Integrated Development Environments
      4. Web Application Platforms
      5. Scripting Languages (JSR-223 compatible)
    2. B. UML Basics
      1. Class Diagrams
        1. Name
        2. Attributes
        3. Operations
        4. Visibility
      2. Object Diagrams
      3. Graphical Icon Representation
        1. Classes, Abstract Classes, and Interfaces
        2. Notes
        3. Packages
      4. Connectors
      5. Multiplicity Indicators
      6. Role Names
      7. Class Relationships
        1. Association
        2. Direct Association
        3. Composition Association
        4. Aggregation Association
        5. Temporary Association
        6. Generalization
        7. Realization
      8. Sequence Diagrams
        1. Participant (1)
        2. Found Message (2)
        3. Synchronous Message (3)
        4. Return Call (4)
        5. Asynchronous Message (5)
        6. Message to Self (6)
        7. Lifeline (7)
        8. Activation Bar (8)
  7. Index
  8. About the Authors
  9. Special Upgrade Offer
  10. Copyright