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 Java example: Salary calculation
1.10 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: Salary 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 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. Generics

12.1 Comparable Interface: Sorting an ArrayList
12.2 Generic methods
12.3 Class generics
12.4 Java example: Map values using a generic method

13. Collections

13.1 Enhanced for loop
13.2 Map: HashMap
13.3 Set: HashSet
13.4 List: LinkedList
13.5 Queue interface
13.6 Deque interface

14. GUI

14.1 Introduction to graphical user interfaces
14.2 Positioning GUI components using a GridBagLayout
14.3 GUI input and ActionListeners
14.4 GUI input with formatted text fields
14.5 GUI input with JSpinners
14.6 Displaying multi-line text in a JTextArea
14.7 Using tables in GUIs
14.8 Using sliders in GUIs
14.9 GUI tables, fields, and buttons: A seat reservation example
14.10 Reading files with a GUI

15. JavaFX

15.1 Introduction to graphical user interfaces with JavaFX
15.2 Positioning GUI components using a GridPane
15.3 Input and event handlers
15.4 Basic graphics with JavaFX

16. Input / Output

16.1 OutputStream and System.out
16.2 InputStream and System.in
16.3 Output formatting
16.4 Streams using Strings
16.5 File input and output

17. Exceptions

17.1 Exception basics
17.2 Exceptions with methods
17.3 Multiple handlers
17.4 Exception handling in file input/output
17.5 Java example: Generate number format exception

18. Recursion

18.1 Recursion: Introduction
18.2 Recursive methods
18.3 Recursive algorithm: Search
18.4 Adding output statements for debugging
18.5 Creating a recursive method
18.6 Recursive math methods
18.7 Recursive exploration of all possibilities
18.8 Stack overflow
18.9 Java example: Recursively output permutations

19. Memory Management

19.1 Introduction to memory management
19.2 A first linked list
19.3 Memory regions: Heap/Stack
19.4 Basic garbage collection
19.5 Garbage collection and variable scope
19.6 Java example: Employee list using ArrayLists

20. Searching and Sorting Alg.

20.1 Searching and algorithms
20.2 Binary search
20.3 O notation
20.4 Algorithm analysis
20.5 Sorting: Introduction
20.6 Selection sort
20.7 Insertion sort
20.8 Quicksort
20.9 Merge sort

21. Additional Material

21.1 Do-while loops
21.2 Example: A Dice Game (EO)
21.3 Engineering examples
21.4 Engineering examples using Methods (EO)
21.5 Command-line arguments
21.6 Command-line arguments and files
21.7 Perfect size arrays
21.8 Oversize arrays
21.9 Methods with oversize arrays
21.10 Comparing perfect size and oversize arrays
21.11 Using references in methods
21.12 Returning arrays from methods
21.13 Common errors: Methods and arrays
21.14 Additional practice: Output art
21.15 Additional practice: Grade calculation
21.16 Additional practice: Tweet decoder
21.17 Additional practice: Dice statistics
21.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