You are previewing Java: A Beginner’s Tutorial, 4th Edition (Updated for Java SE 8).
O'Reilly logo
Java: A Beginner’s Tutorial, 4th Edition (Updated for Java SE 8)

Book Description

This book covers the most important Java programming topics that you need to master to be able to learn other technologies yourself. By fully understanding all the chapters and doing the exercises you’ll be able to perform an intermediate Java programmer’s daily tasks quite well.

Table of Contents

  1. Introduction
    1. Java, the Language and the Technology
    2. An Overview of Object-Oriented Programming
    3. About This Book
    4. Downloading Program Examples and Answers
  2. Chapter 1: Getting Started
    1. Downloading and Installing Java
    2. Your First Java Program
    3. Java Code Conventions
    4. Integrated Development Environments (IDEs)
    5. Summary
    6. Quiz
  3. Chapter 2: Language Fundamentals
    1. ASCII and Unicode
    2. Separators
    3. Primitives
    4. Variables
    5. Constants
    6. Literals
    7. Primitive Conversions
    8. Operators
    9. Comments
    10. Summary
    11. Quiz
  4. Chapter 3: Statements
    1. Overview
    2. The if Statement
    3. The while Statement
    4. The do-while Statement
    5. The for Statement
    6. The break Statement
    7. The continue Statement
    8. The switch Statement
    9. Summary
    10. Quiz
  5. Chapter 4: Objects and Classes
    1. What Is An Object?
    2. Java Classes
    3. Creating An Object
    4. The null Keyword
    5. Memory Allocation for Objects
    6. Java Packages
    7. Encapsulation and Access Control
    8. The this Keyword
    9. Using Other Classes
    10. Final Variables
    11. Static Members
    12. Static Final Variables
    13. Static import
    14. Variable Scope
    15. Method Overloading
    16. Static Factory Methods
    17. By Value or By Reference?
    18. Loading, Linking, and Initialization
    19. Object Creation Initialization
    20. The Garbage Collector
    21. Summary
    22. Quiz
  6. Chapter 5: Core Classes
    1. java.lang.Object
    2. java.lang.String
    3. java.lang.StringBuffer and java.lang.StringBuilder
    4. Primitive Wrappers
    5. java.lang.Class
    6. java.lang.System
    7. java.util.Scanner
    8. Summary
    9. Quiz
  7. Chapter 6: Arrays
    1. Overview
    2. Iterating over an Array
    3. The java.util.Arrays Class
    4. Changing an Array Size
    5. Searching An Array
    6. Passing a String Array to main
    7. Multidimensional Arrays
    8. Summary
    9. Quiz
  8. Chapter 7: Inheritance
    1. Overview
    2. Accessibility
    3. Method Overriding
    4. Calling the Constructors of the Superclass
    5. Calling the Hidden Members of the Superclass
    6. Type Casting
    7. Final Classes
    8. The instanceof Operator
    9. Summary
    10. Quiz
  9. Chapter 8: Error Handling
    1. Catching Exceptions
    2. try without catch
    3. Catching Multiple Exceptions
    4. The try-with-resources Statement
    5. The java.lang.Exception Class
    6. Throwing an Exception from a Method
    7. User-Defined Exceptions
    8. Note on Exception Handling
    9. Summary
    10. Quiz
  10. Chapter 9: Working with Numbers
    1. Boxing and Unboxing
    2. Number Parsing
    3. Number Formatting
    4. Number Parsing with java.text.NumberFormat
    5. The java.lang.Math Class
    6. Working with Money
    7. Generating Random Numbers
    8. Summary
    9. Quiz
  11. Chapter 10: Interfaces and Abstract Classes
    1. The Concept of Interface
    2. The Interface, Technically Speaking
    3. Default Methods
    4. Static Methods
    5. Base Classes
    6. Abstract Classes
    7. Summary
    8. Quiz
  12. Chapter 11: Polymorphism
    1. Overview
    2. Polymorphism in Action
    3. Polymorphism and Reflection
    4. Summary
    5. Quiz
  13. Chapter 12: Enums
    1. Overview
    2. Enums in a Class
    3. The java.lang.Enum Class
    4. Iterating Enumerated Values
    5. Switching on Enum
    6. Enum Members
    7. Summary
    8. Quiz
  14. Chapter 13: Working with Dates and Times
    1. Overview
    2. The Instant Class
    3. LocalDate
    4. Period
    5. LocalDateTime
    6. Time Zones
    7. ZonedDateTime
    8. Duration
    9. Formatting A Date-Time
    10. Parsing A Date-Time
    11. Using the Old Date and Time API
    12. Summary
    13. Quiz
  15. Chapter 14: The Collections Framework
    1. An Overview of the Collections Framework
    2. The Collection Interface
    3. List and ArrayList
    4. Iterating Over a Collection with Iterator and for
    5. Set and HashSet
    6. Queue and LinkedList
    7. Collection Conversion
    8. Map and HashMap
    9. Making Objects Comparable and Sortable
    10. Summary
    11. Quiz
  16. Chapter 15: Generics
    1. Life without Generics
    2. Generic Types
    3. Using Generic Types without Type Parameters
    4. Using the ? Wildcard
    5. Using Bounded Wildcards in Methods
    6. Generic Methods
    7. Writing Generic Types
    8. Summary
    9. Quiz
  17. Chapter 16: Input/Output
    1. File Systems and Paths
    2. File and Directory Handling and Manipulation
    3. Input/Output Streams
    4. Reading Binary Data
    5. Writing Binary Data
    6. Writing Text (Characters)
    7. Reading Text (Characters)
    8. Logging with PrintStream
    9. Random Access Files
    10. Object Serialization
    11. Summary
    12. Quiz
  18. Chapter 17: Annotations
    1. Overview
    2. Standard Annotations
    3. Common Annotations
    4. Standard Meta-Annotations
    5. Custom Annotation Types
    6. Summary
    7. Quiz
  19. Chapter 18: Nested and Inner Classes
    1. An Overview of Nested Classes
    2. Static Nested Classes
    3. Member Inner Classes
    4. Local Inner Classes
    5. Anonymous Inner Classes
    6. Behind Nested and Inner Classes
    7. Summary
    8. Quiz
  20. Chapter 19: Lambda Expressions
    1. Why Lambda Expressions?
    2. Functional Interfaces
    3. Lambda Expression Syntax
    4. Predefined Functional Interfaces
    5. Method References
    6. Optional and Similar Classes
    7. Summary
    8. Quiz
  21. Chapter 20: Working with Streams
    1. Overview
    2. Creating and Obtaining a Stream
    3. Concatenating Streams
    4. Filtering
    5. Mapping
    6. Reduction
    7. Mutable Reductions
    8. Parallel Streams
    9. Summary
    10. Quiz
  22. Chapter 21: Java Database Connectivity
    1. Introduction to JDBC
    2. Four Steps to Data Access
    3. Using Java DB
    4. Using the DAO Pattern
    5. Reading Metadata
    6. Summary
    7. Quiz
  23. Chapter 22: Swing Basics
    1. Overview
    2. AWT Components
    3. Useful AWT Classes
    4. Basic Swing Components
    5. Summary
    6. Quiz
  24. Chapter 23: Swinging Higher
    1. Layout Managers
    2. Event Handling
    3. Working with Menus
    4. The Look and Feel
    5. Fast Splash Screens
    6. System Tray Support
    7. Desktop Help Applications
    8. Summary
    9. Quiz
  25. Chapter 24: Applets
    1. A Brief History of Applets
    2. The Applet API
    3. Security Restrictions
    4. Writing and Deploying Applets
    5. How AppletViewer Works
    6. Passing Parameters to an Applet
    7. SoundPlayerApplet
    8. JApplet
    9. Applet Deployment in a JAR File
    10. Faster Loading
    11. Summary
    12. Quiz
  26. Chapter 25: Introduction to JavaFX
    1. Overview
    2. Setting up
    3. Your First JavaFX Application
    4. The JavaFX API is explained in the next section.Application, Stage, and Scene
    5. UI Components
    6. Controls
    7. Regions
    8. Event Handling
    9. Styling with CSS
    10. Summary
    11. Quiz
  27. Chapter 26: JavaFX with FXML
    1. Overview
    2. A Simple FXML-Based Application
    3. Event Handling with FXML
    4. Summary
    5. Quiz
  28. Chapter 27: Java Threads
    1. Introduction to Java Threads
    2. Creating a Thread
    3. Working with Multiple Threads
    4. Thread Priority
    5. Stopping a Thread
    6. Synchronization
    7. Visibility
    8. Thread Coordination
    9. Using Timers
    10. Swing Timers
    11. Summary
    12. Quiz
  29. Chapter 28: Concurrency Utilities
    1. Atomic Variables
    2. Executor and ExecutorService
    3. Callable and Future
    4. Swing Worker
    5. Locks
    6. Summary
    7. Quiz
  30. Chapter 29: Internationalization
    1. Locales
    2. Internationalizing Applications
    3. An Internationalized Swing Application
    4. Summary
    5. Quiz
  31. Chapter 30: Java Networking
    1. An Overview of Networking
    2. The Hypertext Transfer Protocol (HTTP)
    3. java.net.URL
    4. java.net.URLConnection
    5. java.net.Socket
    6. java.net.ServerSocket
    7. A Web Server Application
    8. Summary
    9. Quiz
  32. Chapter 31: Security
    1. Java Security Overview
    2. Using the Security Manager
    3. Policy Files
    4. Permissions
    5. Using the Policy Tool
    6. Applet Security
    7. Programming with Security
    8. Cryptography Overview
    9. Creating Certificates
    10. The KeyTool Program
    11. The JarSigner Tool
    12. Java Cryptography API
    13. Summary
    14. Quiz
  33. Chapter 32: Java Web Applications
    1. Servlet Application Architecture
    2. Servlet API Overview
    3. Servlet
    4. Writing a Basic Servlet Application
    5. ServletRequest
    6. ServletResponse
    7. ServletConfig
    8. ServletContext
    9. GenericServlet
    10. HTTP Servlets
    11. Using the Deployment Descriptor
    12. Summary
    13. Quiz
  34. Chapter 33: JavaServer Pages
    1. A JSP Overview
    2. jspInit, jspDestroy, and Other Methods
    3. Implicit Objects
    4. JSP Syntactic Elements
    5. Handling Errors
    6. Summary
    7. Quiz
  35. Chapter 34: Javadoc
    1. Overview
    2. Writing Documentation in Java Classes
    3. Javadoc Syntax
    4. Summary
    5. Quiz
  36. Chapter 35: Application Deployment
    1. JWS Overview
    2. JNLP File Syntax
    3. A Deployment Example
    4. Security Concerns
    5. Summary
    6. Quiz
  37. Appendix A: javac
    1. Options
    2. Command Line Argument Files
  38. Appendix B: java
    1. Options
  39. Appendix C: jar
    1. Syntax
    2. Options
    3. Examples
    4. Setting an Application Entry Point
  40. Appendix D: NetBeans
    1. Download and Installation
    2. Creating a Project
    3. Creating a Class
    4. Running a Java Class
    5. Adding Libraries
    6. Debugging Code
  41. Appendix E: Eclipse
    1. Download and Installation
    2. Adding A JRE
    3. Creating a Java Project
    4. Creating a Class
    5. Running a Java Class
    6. Adding Libraries
    7. Debugging Code
    8. Useful Shortcuts
  42. Answers
    1. Chapter 1: Getting Started
    2. Chapter 2: Language Fundamentals
    3. Chapter 3: Statements
    4. Chapter 4: Objects and Classes
    5. Chapter 5: Core Classes
    6. Chapter 6: Arrays
    7. Chapter 7: Inheritance
    8. Chapter 8: Error Handling
    9. Chapter 9: Working with Numbers
    10. Chapter 10: Interfaces and Abstract Classes
    11. Chapter 11: Polymorphism
    12. Chapter 12: Enums
    13. Chapter 13: Working with Dates and Times
    14. Chapter 14: The Collections Framework
    15. Chapter 15: Generics
    16. Chapter 16: Input Output
    17. Chapter 17: Annotations
    18. Chapter 18: Inner Classes
    19. Chapter 19: Lambda Expressions
    20. Chapter 20: Working with Streams
    21. Chapter 21: Java Database Connectivity
    22. Chapter 22: Swing Basics
    23. Chapter 23: Swinging Higher
    24. Chapter 24: Applets
    25. Chapter 25: Introduction to JavaFX
    26. Chapter 26: JavaFX with FXML
    27. Chapter 27: Java Threads
    28. Chapter 28: Concurrency Utilities
    29. Chapter 29: Internationalization
    30. Chapter 30: Java Networking
    31. Chapter 31: Security
    32. Chapter 32: Java Web Applications
    33. Chapter 33: JavaServer Pages
    34. Chapter 34: Javadoc
    35. Chapter 35: Application Deployment