Table of Contents

1. Introduction to Java

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

2. Basic Objects

2.1 Objects: An early introduction (EO)
2.2 Variables and assignments (general)
2.3 Variables (int)
2.4 Identifiers
2.5 Arithmetic expressions (general)
2.6 Arithmetic expressions (int)
2.7 Example: Health data
2.8 Floating-point numbers (double)
2.9 Scientific notation for floating-point literals
2.10 Comments and whitespace
2.11 Calling methods (EO)
2.12 Constructing objects (EO)
2.13 Accessors and mutators (EO)
2.14 Reading API documentation
2.15 Debugging
2.16 Basic graphics
2.17 Style guidelines
2.18 Java example: Salary calculation with variables

3. Basic Methods + Classes

3.1 Using a class
3.2 Defining a class
3.3 Defining main() in a programmer-defined class
3.4 User-defined method basics (EO)
3.5 Return (EO)
3.6 Reasons for defining methods (EO)
3.7 Unit testing (classes)
3.8 The ‘this’ implicit parameter
3.9 Java documentation for classes

4. Data Types

4.1 Constant variables
4.2 Using math methods
4.3 Integer division and modulo
4.4 Type conversions
4.5 Binary
4.6 Characters
4.7 Strings
4.8 Integer overflow
4.9 Numeric data types
4.10 Random numbers
4.11 Java example: Married-couple names with variables

5. Branches

5.1 If-else branches (general)
5.2 If-else
5.3 More if-else
5.4 Equality and relational operators
5.5 Detecting ranges (general)
5.6 Detecting ranges with if-else statements
5.7 Logical operators
5.8 Order of evaluation
5.9 Example: A SimpleCar class
5.10 Example: Toll calculation
5.11 Switch statements
5.12 Boolean data type
5.13 String comparisons
5.14 String access operations
5.15 Character operations
5.16 More string operations
5.17 Conditional expressions
5.18 Floating-point comparison
5.19 Short circuit evaluation
5.20 Java example: Salary calculation with branches
5.21 Java example: Search for name using branches

6. Loops

6.1 Loops (general)
6.2 While loops
6.3 More while examples
6.4 For loops
6.5 More for loop examples
6.6 Loops and strings
6.7 Nested loops
6.8 Developing programs incrementally
6.9 Break and continue
6.10 Variable name scope
6.11 Enumerations
6.12 Java example: Salary calculation with loops
6.13 Java example: Domain name validation with loops

7. Arrays

7.1 Array concept (general)
7.2 Arrays
7.3 Array iteration drill
7.4 Iterating through arrays
7.5 Multiple arrays
7.6 Swapping two variables (General)
7.7 Loop-modifying or copying/comparing arrays
7.8 Debugging example: Reversing an array
7.9 Two-dimensional arrays
7.10 Enhanced for loop: Arrays
7.11 Java example: Annual salary tax rate calculation with arrays
7.12 Java example: Domain name validation with arrays

8. Methods Continued

8.1 Methods with branches/loops (EO)
8.2 Unit testing methods (EO)
8.3 How methods work
8.4 Methods: Common errors (EO)
8.5 Array parameters (EO)
8.6 Scope of variable/method definitions (EO)
8.7 Method name overloading (EO)
8.8 Parameter error checking
8.9 Using Scanner in methods
8.10 Java documentation for methods
8.11 Java example: Salary calculation with methods
8.12 Java example: Domain name validation with methods

9. Classes continued

9.1 Mutators, accessors, and private helpers
9.2 Initialization and constructors
9.3 Constructor overloading
9.4 Objects and references
9.5 Abstract data types: Introduction (EO)
9.6 Primitive and reference types
9.7 ArrayList
9.8 Classes, ArrayLists, and methods: A seat reservation example (EO)
9.9 Choosing classes to create
9.10 ArrayList ADT (EO)
9.11 Parameters of reference types (EO)
9.12 Static fields and methods
9.13 Java example: Salary calculation with classes
9.14 Java example: Domain name availability with classes (EO)

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 Abstract classes: Introduction (generic)
10.8 Abstract classes
10.9 Is-a versus has-a relationships
10.10 UML
10.11 Interfaces
10.12 Java example: Employees and instantiating from an abstract class
10.13 Java example: Employees and overriding class methods

11. Generics

11.1 Comparable Interface: Sorting an ArrayList
11.2 Generic methods
11.3 Class generics
11.4 Java example: Map values using a generic method

12. Collections

12.1 Enhanced for loop
12.2 List: LinkedList
12.3 Map: HashMap
12.4 Set: HashSet
12.5 Queue interface
12.6 Deque interface

13. GUI

13.1 Introduction to graphical user interfaces
13.2 Positioning GUI components using a GridBagLayout
13.3 GUI input and ActionListeners
13.4 GUI input with formatted text fields
13.5 GUI input with JSpinners
13.6 Displaying multi-line text in a JTextArea
13.7 Using tables in GUIs
13.8 Using sliders in GUIs
13.9 GUI tables, fields, and buttons: A seat reservation example
13.10 Reading files with a GUI

14. JavaFX

14.1 Introduction to graphical user interfaces with JavaFX
14.2 Positioning GUI components using a GridPane
14.3 Input and event handlers
14.4 Basic graphics with JavaFX

15. Input / Output

15.1 Output and input streams
15.2 Output formatting
15.3 Streams using Strings
15.4 File input
15.5 File output

16. Exceptions

16.1 Exception basics
16.2 Exceptions with methods
16.3 Multiple handlers
16.4 Exception handling in file input/output
16.5 Java example: Generate number format exception

17. Recursion

17.1 Recursion: Introduction
17.2 Recursive methods
17.3 Recursive algorithm: Search
17.4 Adding output statements for debugging
17.5 Creating a recursive method
17.6 Recursive math methods
17.7 Recursive exploration of all possibilities
17.8 Stack overflow
17.9 Java example: Recursively output permutations

18. Memory Management

18.1 Introduction to memory management
18.2 A first linked list
18.3 Memory regions: Heap/Stack
18.4 Basic garbage collection
18.5 Garbage collection and variable scope
18.6 Java example: Employee list using ArrayLists

19. Searching and Sorting Algorithms

19.1 Searching and algorithms
19.2 Binary search
19.3 O notation
19.4 Algorithm analysis
19.5 Sorting: Introduction
19.6 Selection sort
19.7 Insertion sort
19.8 Quicksort
19.9 Merge sort

20. Additional Material

20.1 Do-while loops
20.2 Example: A Dice Game (EO)
20.3 Engineering examples
20.4 Engineering examples using Methods (EO)
20.5 Command-line arguments
20.6 Command-line arguments and files
20.7 Perfect size arrays
20.8 Oversize arrays
20.9 Methods with oversize arrays
20.10 Comparing perfect size and oversize arrays
20.11 Using references in methods
20.12 Returning arrays from methods
20.13 Common errors: Methods and arrays
20.14 Additional practice: Output art
20.15 Additional practice: Grade calculation
20.16 Additional practice: Tweet decoder
20.17 Additional practice: Dice statistics
20.18 zyBooks built-in programming window

What You’ll Find In This zyBook:

More action with less text.

  • ~600 participation activities: Questions, animations, tools
  • ~100 auto-graded programming challenge activities using built-in programming environment
  • Customized for early use of objects, both built-in and user-defined
  • Additional material includes command-line arguments and engineering examples

Instructors: Interested in evaluating this zyBook for your class? Sign up for a Free Trial and check out the first chapter of any zyBook today!

The zyBooks Approach

Less text doesn’t mean less learning.

Provides interactive learning of programming foundations and Java. Emphasizes a solid understanding of memory. From the moment variables are introduced, the material shows via animations how variables exist and are updated in memory. The continued showing of memory helps clarify challenging topics like pass-by-copy/reference parameters, object creation, garbage collection, and more. Furthermore, the material includes emphasis on disciplined program development, including incremental development, modular development, and testing/debugging. This material is primarily a re-ordering of the “Programming in Java” zyBook to support an early objects introduction, with a few sections added to improve content flow.

This zyBook can also be mix-and-matched with others, such as with Data Structures Essentials (a popular combination).

“The most striking aspect of ZyBooks for me as an instructor has been the ability to introduce a topic and then point my students to specific exercises/activities in ZyBooks that would not only expound on the concept but allow them to practice them with confidence.”

Ramesh YerraballiSenior Lecturer Dept. of Electrical & Comp Engrs, UT Austin

Authors

Roman Lysecky
Professor of Electrical and Computer Engineering, Univ. of Arizona

Adrian Lizarraga
zyBooks, ECE Ph, D., University of Arizona