Programming in Java
Roman Lysecky | Adrian Lizarraga
zyBooks 2017

Table of Contents

1. Introduction to Java
1.1 Programming (general)
1.2 Programming basics
1.3 Comments and whitespace
1.4 Errors and warnings
1.5 Computers and programs (general)
1.6 Computer tour
1.7 Language history
1.8 Problem solving
1.9 Why programming
1.10 Java example: Salary calculation
1.11 Java example: Married-couple names

2. Variables / Assignments
2.1 Variables and assignments (general)
2.2 Variables (int)
2.3 Identifiers
2.4 Arithmetic expressions (general)
2.5 Arithmetic expressions (int)
2.6 Example: Health data
2.7 Floating-point numbers (double)
2.8 Scientific notation for floating-point literals
2.9 Constant variables
2.10 Using math methods
2.11 Integer division and modulo
2.12 Type conversions
2.13 Binary
2.14 Characters
2.15 Strings
2.16 Integer overflow
2.17 Numeric data types
2.18 Random numbers
2.19 Reading API documentation
2.20 Debugging
2.21 Style guidelines
2.22 Java example: Salary calculation with variables
2.23 Java example: Married-couple names with variables

3. Branches
3.1 If-else branches (general)
3.2 If-else
3.3 More if-else
3.4 Equality and relational operators
3.5 Detecting ranges (general)
3.6 Detecting ranges with if-else statements
3.7 Logical operators
3.8 Order of evaluation
3.9 Example: Toll calculation
3.10 Switch statements
3.11 Boolean data type
3.12 String comparisons
3.13 String access operations
3.14 Character operations
3.15 More string operations
3.16 Conditional expressions
3.17 Floating-point comparison
3.18 Short circuit evaluation
3.19 Java example: Salary calculation with branches
3.20 Java example: Search for name using branches

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

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

6. User-Defined Methods
6.1 User-defined method basics
6.2 Return
6.3 Reasons for defining methods
6.4 Methods with branches/loops
6.5 Unit testing (methods)
6.6 How methods work
6.7 Methods: Common errors
6.8 Array parameters
6.9 Scope of variable/method definitions
6.10 Method name overloading
6.11 Parameter error checking
6.12 Using Scanner in methods
6.13 Perfect size arrays
6.14 Oversize arrays
6.15 Methods with oversize arrays
6.16 Comparing perfect size and oversize arrays
6.17 Using references in methods
6.18 Returning arrays from methods
6.19 Common errors: Methods and arrays
6.20 Java documentation for methods
6.21 Java example: Salary calculation with methods
6.22 Java example: Domain name validation with methods

7. Objects and Classes
7.1 Objects: Introduction
“7.2 Using a class
7.3 Defining a class
7.7 Defining main() in a programmer-defined class”
7.4 Mutators, accessors, and private helpers
7.5 Initialization and constructors
7.6 Choosing classes to create
7.8 Unit testing (classes)
7.9 Constructor overloading
7.10 Objects and references
7.11 The ‘this’ implicit parameter
7.12 Primitive and reference types
7.13 ArrayList
7.14 Classes, ArrayLists, and methods: A seat reservation example
7.15 ArrayList ADT
7.16 Java documentation for classes
7.17 Parameters of reference types
7.20 Static fields and methods
7.18 Java example: Salary calculation with classes
7.19 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. Searching and Sorting Alg.
18.1 Searching and algorithms
18.2 Binary search
18.3 O notation
18.4 Algorithm analysis
18.5 Sorting: Introduction
18.6 Selection sort
18.7 Insertion sort
18.8 Quicksort
18.9 Merge sort

19. Additional Material
19.1 Do-while loops
19.2 Engineering examples
19.3 Engineering examples using methods
19.4 Command-line arguments
19.5 Command-line arguments and files
19.6 Additional practice: Output art
19.7 Additional practice: Grade calculation
19.8 Additional practice: Tweet decoder
19.9 Additional practice: Dice statistics
19.10 zyBooks built-in programming window