You are previewing The Java® Tutorial: A Short Course on the Basics, Sixth Edition.
O'Reilly logo
The Java® Tutorial: A Short Course on the Basics, Sixth Edition

Book Description

The Java® Tutorial, Sixth Edition, is based on the Java Platform, Standard Edition (Java SE) 8. This revised and updated edition introduces the new features added to the platform, including lambda expressions, default methods, aggregate operations, and more. An accessible and practical guide for programmers of any level, this book focuses on how to use the rich environment provided by Java to build applications, applets, and components.

Expanded coverage includes a chapter on the Date-Time API and a new chapter on annotations, with sections on type annotations and pluggable type systems as well as repeating annotations.

In addition, the updated sections “Security in Rich Internet Applications” and “Guidelines for Securing Rich Internet Applications” address key security topics. The latest deployment best practices are described in the chapter “Deployment in Depth.”

If you plan to take one of the Java SE 8 certification exams, this book can help. A special appendix, “Preparing for Java Programming Language Certification,” details the items covered on the available exams. Check online for updates.

All of the material has been thoroughly reviewed by members of Oracle Java engineering to ensure that the information is accurate and up to date. This book is based on the online tutorial hosted on Oracle Corporation’s website at http://docs.oracle.com/javase/tutorial.

Table of Contents

  1. Contents
  2. Preface
    1. Who Should Read This Book?
    2. How to Use This Book
  3. Acknowledgements
  4. About the Authors
  5. Chapter 1. Getting Started
    1. The Java Technology Phenomenon
    2. What Can Java Technology Do?
    3. How Will Java Technology Change My Life?
    4. The “Hello World!” Application
    5. “Hello World!” for the NetBeans IDE
    6. “Hello World!” for Microsoft Windows
    7. “Hello World!” for Solaris OS and Linux
    8. A Closer Look at the “Hello World!” Application
    9. Common Problems (and Their Solutions)
    10. Questions and Exercises: Getting Started
    11. Chapter 1 Notes
  6. Chapter 2. Object-Oriented Programming Concepts
    1. What Is an Object?
    2. What Is a Class?
    3. What Is Inheritance?
    4. What Is an Interface?
    5. What Is a Package?
    6. Questions and Exercises: Object-Oriented Programming Concepts
  7. Chapter 3. Language Basics
    1. Variables
    2. Operators
    3. Expressions, Statements, and Blocks
    4. Control Flow Statements
    5. Chapter 3 Notes
  8. Chapter 4. Classes and Objects
    1. Classes
    2. Objects
    3. More on Classes
    4. Nested Classes
    5. Enum Types
    6. Chapter 4 Notes
  9. Chapter 5. Annotations
    1. Annotations Basics
    2. Declaring an Annotation Type
    3. Predefined Annotation Types
    4. Type Annotations and Pluggable Type Systems
    5. Repeating Annotations
    6. Questions and Exercises: Annotations
    7. Chapter 5 Notes
  10. Chapter 6. Interfaces and Inheritance
    1. Interfaces
    2. Inheritance
    3. Chapter 6 Notes
  11. Chapter 7. Generics
    1. Why Use Generics?
    2. Generic Types
    3. Generic Methods
    4. Bounded Type Parameters
    5. Generics, Inheritance, and Subtypes
    6. Type Inference
    7. Wildcards
    8. Type Erasure
    9. Restrictions on Generics
    10. Questions and Exercises: Generics
    11. Chapter 7 Notes
  12. Chapter 8. Packages
    1. Creating and Using Packages
    2. Questions and Exercises: Creating and Using Packages
  13. Chapter 9. Numbers and Strings
    1. Numbers
    2. Characters
    3. Strings
    4. Chapter 9 Notes
  14. Chapter 10. Exceptions
    1. What Is an Exception?
    2. The Catch or Specify Requirement
    3. Catching and Handling Exceptions
    4. Specifying the Exceptions Thrown by a Method
    5. How to Throw Exceptions
    6. Unchecked Exceptions—The Controversy
    7. Advantages of Exceptions
    8. Summary
    9. Questions and Exercises: Exceptions
    10. Chapter 10 Notes
  15. Chapter 11. Basic I/O and NIO.2
    1. I/O Streams
    2. File I/O (Featuring NIO.2)
    3. Summary
    4. Questions and Exercises: Basic I/O
    5. Chapter 11 Notes
  16. Chapter 12. Collections
    1. Introduction to Collections
    2. Interfaces
    3. Aggregate Operations
    4. Implementations
    5. Algorithms
    6. Custom Collection Implementations
    7. Interoperability
    8. Chapter 12 Notes
  17. Chapter 13. Concurrency
    1. Processes and Threads
    2. Thread Objects
    3. Synchronization
    4. Liveness
    5. Guarded Blocks
    6. Immutable Objects
    7. High Level Concurrency Objects
    8. Questions and Exercises: Concurrency
    9. Chapter 13 Notes
  18. Chapter 14. Regular Expressions
    1. Introduction
    2. Test Harness
    3. String Literals
    4. Character Classes
    5. Predefined Character Classes
    6. Quantifiers
    7. Capturing Groups
    8. Boundary Matchers
    9. Methods of the Pattern Class
    10. Methods of the Matcher Class
    11. Methods of the PatternSyntaxException Class
    12. Unicode Support
    13. Additional Resources
    14. Questions and Exercises: Regular Expressions
    15. Chapter 14 Notes
  19. Chapter 15. The Platform Environment
    1. Configuration Utilities
    2. System Utilities
    3. PATH and CLASSPATH
    4. Questions and Exercises: The Platform Environment
    5. Chapter 15 Notes
  20. Chapter 16. Packaging Programs in JAR Files
    1. Using JAR Files: The Basics
    2. Working with Manifest Files: The Basics
    3. Signing and Verifying JAR Files
    4. Using JAR-Related APIs
    5. Questions and Exercises: Packaging Programs in JAR Files
    6. Chapter 16 Notes
  21. Chapter 17. Java Web Start
    1. Additional References
    2. Developing a Java Web Start Application
    3. Deploying a Java Web Start Application
    4. Displaying a Customized Loading Progress Indicator
    5. Running a Java Web Start Application
    6. Java Web Start and Security
    7. Common Java Web Start Problems
    8. Questions and Exercises: Java Web Start
    9. Chapter 17 Notes
  22. Chapter 18. Applets
    1. Getting Started with Applets
    2. Doing More with Applets
    3. Solving Common Applet Problems
    4. Questions and Exercises: Applets
    5. Chapter 18 Notes
  23. Chapter 19. Doing More with Java Rich Internet Applications
    1. Setting Trusted Arguments and Secure Properties
    2. JNLP API
    3. Cookies
    4. Customizing the Loading Experience
    5. Security in Rich Internet Applications
    6. Guidelines for Securing Rich Internet Applications
    7. Questions and Exercises: Doing More with Rich Internet Applications
    8. Chapter 19 Notes
  24. Chapter 20. Deployment In Depth
    1. User Acceptance of RIAs
    2. Deployment Toolkit
    3. Java Network Launch Protocol
    4. Deployment Best Practices
    5. Questions and Exercises: Deployment In Depth
    6. Chapter 20 Notes
  25. Chapter 21. Introduction to JavaFX
  26. Appendix. Preparation for Java Programming Language Certification
    1. Programmer Level I Exam
    2. Programmer Level II Exam
    3. Java SE 8 Upgrade Exam
    4. Appendix. Notes