Programming in Java
Roman Lysecky | Adrian Lizarraga
zyBooks 2017

Table of Contents

1. Introduction to Java
1.1 Programming
1.2 A first program
1.3 Basic output
1.4 Basic input
1.5 Comments and whitespace
1.6 Errors and warnings
1.7 Computers and programs
1.8 Computer tour
1.9 Language history
1.10 Problem solving
1.11 Java example: Salary calculation
1.12 Java example: Married-couple names

2. Variables / Assignments
2.1 Variables (int)
2.2 Assignments
2.3 Identifiers
2.4 Arithmetic expressions (int)
2.5 Floating-point numbers (double)
2.6 Constant variables
2.7 Using math methods
2.8 Type conversions
2.9 Binary
2.10 Characters
2.11 String basics
2.12 Integer overflow
2.13 Numeric data types
2.14 Random numbers
2.15 Reading API documentation
2.16 Debugging
2.17 Style guidelines
2.18 Java example: Salary calculation with variables
2.19 Java example: Married-couple names with variables

3. Branches
3.1 If-else
3.2 Relational and equality operators
3.3 Multiple if-else branches
3.4 Logical operators
3.5 Switch statements
3.6 Boolean data types
3.7 String comparisons
3.8 String access operations
3.9 String modify operations
3.10 Character operations
3.11 Conditional expressions
3.12 Floating-point comparison
3.13 Short circuit evaluation
3.14 Java example: Salary calculation with branches
3.15 Java example: Search for name using branches

4. Loops
4.1 Loops
4.2 While loops
4.3 More while examples
4.4 Counting
4.5 For loops
4.6 Nested loops
4.7 Developing programs incrementally
4.8 Break and continue
4.9 Variable name scope
4.10 Enumerations
4.11 Java example: Salary calculation with loops
4.12 Java example: Domain name validation with loops

5. Arrays
5.1 Array concept
5.2 Arrays
5.3 Array iteration drill
5.4 Iterating through arrays
5.5 Multiple arrays
5.6 Swapping two variables
5.7 Loop-modifying or copying/comparing arrays
5.8 Debugging example: Reversing an array
5.9 Two-dimensional arrays
5.10 Java example: Salary calculation with arrays
5.11 Java example: Domain name validation with arrays

6. User-Defined Methods
6.1 User-defined method basics
6.2 Parameters
6.3 Return
6.4 Reasons for defining methods
6.5 Methods with branches/loops
6.6 Unit testing (methods)
6.7 How methods work
6.8 Methods: Common errors
6.9 Array parameters
6.10 Scope of variable/method definitions
6.11 Method name overloading
6.12 Java documentation for methods
6.13 Java example: Salary calculation with methods
6.14 Java example: Domain name validation with methods

7. Objects and Classes
7.1 Objects: Introduction
7.2 Classes: Introduction
7.3 Mutators, accessors, and private helpers
7.4 Constructors
7.5 Constructor overloading
7.6 Unit testing (classes)
7.7 Objects and references
7.8 The ‘this’ implicit parameter
7.9 Abstract data types: Introduction
7.10 Primitive and reference types
7.11 ArrayList
7.12 Classes, ArrayLists, and methods: A seat reservation example
7.13 Classes with classes
7.14 ArrayList ADT
7.15 Java documentation for classes
7.16 Parameters of reference types
7.17 Java example: Salary calculation with classes
7.18 Java example: Domain name availability with classes

8. Memory Management
8.1 Introduction to memory management
8.2 A first linked list
8.3 Memory regions: Heap/Stack
8.4 Basic garbage collection
8.5 Garbage collection and variable scope
8.6 Java example: Employee list using ArrayLists

9. Input / Output
9.1 OutputStream and System.out
9.2 InputStream and System.in
9.3 Output formatting
9.4 Streams using Strings
9.5 File input and output

10. Inheritance
10.1 Derived classes
10.2 Access by members of derived classes
10.3 Overriding member methods
10.4 The Object class
10.5 Polymorphism
10.6 ArrayLists of Objects
10.7 Is-a versus has-a relationships
10.8 Java example: Employees and overriding class methods

11. Abstract Class and Interfaces
11.1 Abstract classes: Introduction
11.2 Abstract classes
11.3 UML for abstract classes
11.4 Abstract classes and polymorphism
11.5 Interfaces
11.6 Java example: Employees and instantiating from an abstract class

12. Recursion
12.1 Recursion: Introduction
12.2 Recursive methods
12.3 Recursive algorithm: Search
12.4 Adding output statements for debugging
12.5 Creating a recursive method
12.6 Recursive math methods
12.7 Recursive exploration of all possibilities
12.8 Stack overflow
12.9 Java example: Recursively output permutations

13. Exceptions
13.1 Exception basics
13.2 Exceptions with methods
13.3 Multiple handlers
13.4 Exception handling in file input/output
13.5 Java example: Generate number format exception

14. Generics
14.1 Comparable Interface: Sorting an ArrayList
14.2 Generic methods
14.3 Class generics
14.4 Java example: Map values using a generic method

15. Collections
15.1 Enhanced for loop
15.2 Map: HashMap
15.3 Set: HashSet
15.4 List: LinkedList
15.5 Queue interface
15.6 Deque interface

16. GUI
16.1 Basic graphics
16.2 Introduction to graphical user interfaces
16.3 Positioning GUI components using a GridBagLayout
16.4 GUI input and ActionListeners
16.5 GUI input with formatted text fields
16.6 GUI input with JSpinners
16.7 Displaying multi-line text in a JTextArea
16.8 Using tables in GUIs
16.9 Using sliders in GUIs
16.10 GUI tables, fields, and buttons: A seat reservation example
16.11 Reading files with a GUI

17. JavaFX
17.1 Introduction to graphical user interfaces with JavaFX
17.2 Positioning GUI components using a GridPane
17.3 Input and event handlers
17.4 Basic graphics with JavaFX

18. Additional Material
18.1 Do-while loops
18.2 Engineering examples
18.3 Engineering examples using methods
18.4 Command-line arguments
18.5 Command-line arguments and files
18.6 Additional practice: Output art
18.7 Additional practice: Grade calculation
18.8 Additional practice: Health data
18.9 Additional practice: Tweet decoder
18.10 Additional practice: Dice statistics
18.11 zyBooks built-in programming window