Java 9 for Programmers

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Author(s): Paul Deitel & Harvey Deitel
Edition: Deitel Developer Series

Language: English

Title Page
Copyright Page
Detication Page
Contents
Deitel® Series
Trademarks
Foreword
Preface
Before You Begin
1. Introduction and Test-Driving a Java Application
1.1 Introduction
1.2 Object Technology Concepts
1.3 Java
1.4 A Typical Java Development Environment
1.5 Test-Driving a Java Application
1.6 Software Technologies
1.7 Getting Your Questions Answered
2. Introduction to Java Applications; Input/Output and Operators
2.1 Introduction
2.2 Your First Program in Java: Printing a Line of Text
2.3 Modifying Your First Java Program
2.4 Displaying Text with printf
2.5 Another Application: Adding Integers
2.6 Arithmetic
2.7 Decision Making: Equality and Relational Operators
2.8 Wrap-Up
3. Introduction to Classes, Objects, Methods and Strings
3.1 Introduction
3.2 Instance Variables, set Methods and get Methods
3.3 Account Class: Initializing Objects with Constructors
3.4 Account Class with a Balance; Floating-Point Numbers
3.5 Primitive Types vs. Reference Types
3.6 Wrap-Up
4. Control Statements: Part 1; Assignment, ++ and -- Operators
4.1 Introduction
4.2 Control Structures
4.3 if Single-Selection Statement
4.4 if...else Double-Selection Statement
4.5 while Iteration Statement
4.6 Counter-Controlled Iteration
4.7 Sentinel-Controlled Iteration
4.8 Nesting Different Control Statements
4.9 Compound Assignment Operators
4.10 Increment and Decrement Operators
4.11 Primitive Types
4.12 Wrap-Up
5. Control Statements: Part 2; Logical Operators
5.1 Introduction
5.2 Essentials of Counter-Controlled Iteration
5.3 for Iteration Statement
5.4 Examples Using the for Statement
5.5 do...while Iteration Statement
5.6 switch Multiple-Selection Statement
5.7 Class AutoPolicy: Strings in switch Statements
5.8 break and continue Statements
5.9 Logical Operators
5.10 Wrap-Up
6. Methods: A Deeper Look
6.1 Introduction
6.2 Program Units in Java
6.3 static Methods, static Fields and Class Math
6.4 Methods with Multiple Parameters
6.5 Notes on Declaring and Using Methods
6.6 Argument Promotion and Casting
6.7 Java API Packages
6.8 Case Study: Secure Random-Number Generation
6.9 Case Study: A Game of Chance; Introducing enum Types
6.10 Scope of Declarations
6.11 Method Overloading
6.12 Wrap-Up
7. Arrays and ArrayLists
7.1 Introduction
7.2 Arrays
7.3 Declaring and Creating Arrays
7.4 Examples Using Arrays
7.5 Exception Handling: Processing the Incorrect Response
7.6 Case Study: Card Shuffling and Dealing Simulation
7.7 Enhanced for Statement
7.8 Passing Arrays to Methods
7.9 Pass-By-Value vs. Pass-By-Reference
7.10 Case Study: Class GradeBook Using an Array to Store Grades
7.11 Multidimensional Arrays
7.12 Case Study: Class GradeBook Using a Two-Dimensional Array
7.13 Variable-Length Argument Lists
7.14 Using Command-Line Arguments
7.15 Class Arrays
7.16 Introduction to Collections and Class ArrayList
7.17 Wrap-Up
8. Classes and Objects: A Deeper Look
8.1 Introduction
8.2 Time Class Case Study
8.3 Controlling Access to Members
8.4 Referring to the Current Object’s Members with the this Reference
8.5 Time Class Case Study: Overloaded Constructors
8.6 Default and No-Argument Constructors
8.7 Notes on Set and Get Methods
8.8 Composition
8.9 enum Types
8.10 Garbage Collection
8.11 static Class Members
8.12 static Import
8.13 final Instance Variables
8.14 Package Access
8.15 Using BigDecimal for Precise Monetary Calculations
8.16 JavaMoney API
8.17 Time Class Case Study: Creating Packages
8.18 Wrap-Up
9. Object-Oriented Programming: Inheritance
9.1 Introduction
9.2 Superclasses and Subclasses
9.3 protected Members
9.4 Relationship Between Superclasses and Subclasses
9.5 Constructors in Subclasses
9.6 Class Object
9.7 Designing with Composition vs. Inheritance
9.8 Wrap-Up
10. Object--Oriented Programming: Polymorphism and Interfaces
10.1 Introduction
10.2 Polymorphism Examples
10.3 Demonstrating Polymorphic Behavior
10.4 Abstract Classes and Methods
10.5 Case Study: Payroll System Using Polymorphism
10.6 Allowed Assignments Between Superclass and Subclass Variables
10.7 final Methods and Classes
10.8 A Deeper Explanation of Issues with Calling Methods from Constructors
10.9 Creating and Using Interfaces
10.10 Java SE 8 Interface Enhancements
10.11 Java SE 9 private Interface Methods
10.12 private Constructors
10.13 Program to an Interface, Not an Implementation
10.14 Wrap-Up
11. Exception Handling: A Deeper Look
11.1 Introduction
11.2 Example: Divide by Zero without Exception Handling
11.3 Example: Handling ArithmeticExceptions and InputMismatchExceptions
11.4 When to Use Exception Handling
11.5 Java Exception Hierarchy
11.6 finally Block
11.7 Stack Unwinding and Obtaining Information from an Exception
11.8 Chained Exceptions
11.9 Declaring New Exception Types
11.10 Preconditions and Postconditions
11.11 Assertions
11.12 try-with-Resources: Automatic Resource Deallocation
11.13 Wrap-Up
12. JavaFX Graphical User Interfaces: Part 1
12.1 Introduction
12.2 JavaFX Scene Builder
12.3 JavaFX App Window Structure
12.4 Welcome App—Displaying Text and an Image
12.5 Tip Calculator App—Introduction to Event Handling
12.6 Features Covered in the Other JavaFX Chapters
12.7 Wrap-Up
13. JavaFX GUI: Part 2
13.1 Introduction
13.2 Laying Out Nodes in a Scene Graph
13.3 Painter App: RadioButtons, Mouse Events and Shapes
13.4 Color Chooser App: Property Bindings and Property Listeners
13.5 Cover Viewer App: Data-Driven GUIs with JavaFX Collections
13.6 Cover Viewer App: Customizing ListView Cells
13.7 Additional JavaFX Capabilities
13.8 JavaFX 9: Java SE 9 JavaFX Updates
13.9 Wrap-Up
14. Strings, Characters and Regular Expressions
14.1 Introduction
14.2 Fundamentals of Characters and Strings
14.3 Class String
14.4 Class StringBuilder
14.5 Class Character
14.6 Tokenizing Strings
14.7 Regular Expressions, Class Pattern and Class Matcher
14.8 Wrap-Up
15. Files, Input/Output Streams, NIO and XML Serialization
15.1 Introduction
15.2 Files and Streams
15.3 Using NIO Classes and Interfaces to Get File and Directory Information
15.4 Sequential Text Files
15.5 XML Serialization
15.6 FileChooser and DirectoryChooser Dialogs
15.7 (Optional) Additional java.io Classes
15.8 Wrap-Up
16. Generic Collections
16.1 Introduction
16.2 Collections Overview
16.3 Type-Wrapper Classes
16.4 Autoboxing and Auto-Unboxing
16.5 Interface Collection and Class Collections
16.6 Lists
16.7 Collections Methods
16.8 Class PriorityQueue and Interface Queue
16.9 Sets
16.10 Maps
16.11 Synchronized Collections
16.12 Unmodifiable Collections
16.13 Abstract Implementations
16.14 Java SE 9: Convenience Factory Methods for Immutable Collections
16.15 Wrap-Up
17. Lambdas and Streams
17.1 Introduction
17.2 Streams and Reduction
17.3 Mapping and Lambdas
17.4 Filtering
17.5 How Elements Move Through Stream Pipelines
17.6 Method References
17.7 IntStream Operations
17.8 Functional Interfaces
17.9 Lambdas: A Deeper Look
17.10 Stream Manipulations
17.11 Stream Manipulations
17.12 Stream Manipulations
17.13 Creating a Stream from a File
17.14 Streams of Random Values
17.15 Infinite Streams
17.16 Lambda Event Handlers
17.17 Additional Notes on Java SE 8 Interfaces
17.18 Wrap-Up
18. Recursion
Outline
18.1 Introduction
18.2 Recursion Concepts
18.3 Example Using Recursion: Factorials
18.4 Reimplementing Class FactorialCalculator Using BigInteger
18.5 Example Using Recursion: Fibonacci Series
18.6 Recursion and the Method-Call Stack
18.7 Recursion vs. Iteration
18.8 Towers of Hanoi
18.9 Fractals
18.10 Recursive Backtracking
18.11 Wrap-Up
19. Generic Classes and Methods: A Deeper Look
19.1 Introduction
19.2 Motivation for Generic Methods
19.3 Generic Methods: Implementation and Compile-Time Translation
19.4 Additional Compile-Time Translation Issues: Methods That Use a Type Parameter as the Return Type
19.5 Overloading Generic Methods
19.6 Generic Classes
19.7 Wildcards in Methods That Accept Type Parameters
19.8 Wrap-Up
20. JavaFX Graphics, Animation and Video
20.1 Introduction
20.2 Controlling Fonts with Cascading Style Sheets (CSS)
20.3 Displaying Two-Dimensional Shapes
20.4 Polylines, Polygons and Paths
20.5 Transforms
20.6 Playing Video with Media, MediaPlayer and MediaViewer
20.7 Transition Animations
20.8 Timeline Animations
20.9 Frame-by-Frame Animation with AnimationTimer
20.10 Drawing on a Canvas
20.11 Three-Dimensional Shapes
20.12 Wrap-Up
21. Concurrency and Multi-Core Performance
21.1 Introduction
21.2 Thread States and Life Cycle
21.3 Creating and Executing Threads with the Executor Framework
21.4 Thread Synchronization
21.5 Producer/Consumer Relationship without Synchronization
21.6 Producer/Consumer Relationship: ArrayBlockingQueue
21.7 (Advanced) Producer/Consumer Relationship with synchronized, wait, notify and notifyAll
21.8 (Advanced) Producer/Consumer Relationship: Bounded Buffers
21.9 (Advanced) Producer/Consumer Relationship: The Lock and Condition Interfaces
21.10 Concurrent Collections
21.11 Multithreading in JavaFX
21.12 sort/parallelSort Timings with the Java SE 8 Date/Time API
21.13 Java SE 8: Sequential vs. Parallel Streams
21.14 (Advanced) Interfaces Callable and Future
21.15 (Advanced) Fork/Join Framework
21.16 Wrap-Up
22. Accessing Databases with JDBC
22.1 Introduction
22.2 Relational Databases
22.3 A books Database
22.4 SQL
22.5 Setting Up a Java DB Database
22.6 Connecting to and Querying a Database
22.7 Querying the books Database
22.8 RowSet Interface
22.9 PreparedStatements
22.10 Stored Procedures
22.11 Transaction Processing
22.12 Wrap-Up
23. Introduction to JShell: Java 9’s REPL for Interactive Java
23.1 Introduction
23.2 Installing JDK 9
23.3 Introduction to JShell
23.4 Command-Line Input in JShell
23.5 Declaring and Using Classes
23.6 Discovery with JShell Auto-Completion
23.7 Exploring a Class’s Members and Viewing Documentation
23.8 Declaring Methods
23.9 Exceptions
23.10 Importing Classes and Adding Packages to the CLASSPATH
23.11 Using an External Editor
23.12 Summary of JShell Commands
23.13 Keyboard Shortcuts for Snippet Editing
23.14 How JShell Reinterprets Java for Interactive Use
23.15 IDE JShell Support
23.16 Wrap-Up
24. Java Persistence API (JPA)
24.1 Introduction
24.2 JPA Technology Overview
24.3 Querying a Database with JPA
24.4 Named Queries; Accessing Data from Multiple Tables
24.5 Address Book: Using JPA and Transactions to Modify a Database
24.6 Web Resources
24.7 Wrap-Up
25. ATM Case Study, Part 1: Object-Oriented Design with the UML
25.1 Case Study Introduction
25.2 Examining the Requirements Document
25.3 Identifying the Classes in a Requirements Document
25.4 Identifying Class Attributes
25.5 Identifying Objects’ States and Activities
25.6 Identifying Class Operations
25.7 Indicating Collaboration Among Objects
25.8 Wrap-Up
26. ATM Case Study Part 2: Implementing an Object-Oriented Design
26.1 Introduction
26.2 Starting to Program the Classes of the ATM System
26.3 Incorporating Inheritance and Polymorphism into the ATM System
26.4 ATM Case Study Implementation
26.5 Wrap-Up
27. Java Platform Module System
27.1 Introduction
27.2 Module Declarations
27.3 Modularized Welcome App
27.4 Creating and Using a Custom Module
27.5 Module-Dependency Graphs: A Deeper Look
27.6 Migrating Code to Java 9
27.7 Resources in Modules; Using an Automatic Module
27.8 Creating Custom Runtimes with jlink
27.9 Services and ServiceLoader
27.10 Wrap-Up
28. Additional Java 9 Topics
28.1 Introduction
28.2 Recap: Java 9 Features Covered in Earlier Chapters
28.3 New Version String Format
28.4 Regular Expressions: New Matcher Class Methods
28.5 New Stream Interface Methods
28.6 Modules in JShell
28.7 JavaFX 9 Skin APIs
28.8 Other GUI and Graphics Enhancements
28.9 Security Related Java 9 Topics
28.10 Other Java 9 Topics
28.11 Items Removed from the JDK and Java 9
28.12 Items Proposed for Removal from Future Java Versions
28.13 Wrap-Up
A. Operator Precedence Chart
B. ASCII Character Set
C. Keywords and Reserved Words
D. Primitive Types
E. Bit Manipulation
E.1 Introduction
E.2 Bit Manipulation and the Bitwise Operators
E.3 BitSet Class
F. Labeled break and continue Statements
F.1 Introduction
F.2 Labeled break Statement
F.3 Labeled continue Statement
Index
Code Snippets