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 Integrated development environment
1.7 Computer tour
1.8 Language history
1.9 Problem solving
1.10 Why programming
1.11 Why whitespace matters
1.12 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
2.23 Java example: Salary calculation with variables
2.24 Java example: Married-couple names with variables
3. Branches
3.1 If-else branches (general)
3.2 Detecting equal values with branches
3.3 Detecting ranges with branches (general)
3.4 Detecting ranges with branches
3.5 Detecting ranges using logical operators
3.6 Detecting ranges with gaps
3.7 Detecting multiple features with branches
3.8 Common branching errors
3.9 Example: Toll calculation
3.10 Order of evaluation
3.11 Switch statements
3.12 Boolean data type
3.13 String comparisons
3.14 String access operations
3.15 Character operations
3.16 Finding and replacing text in a string
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: Annual salary tax rate calculation with arrays
5.12 Java example: Domain name validation with arrays
6. User-Defined Methods
6.1 User-defined method basics
6.2 Print methods
6.3 Reasons for defining methods
6.4 Writing mathematical methods
6.5 Methods with branches
6.6 Methods with loops
6.7 Unit testing (methods)
6.8 How methods work
6.9 Methods: Common errors
6.10 Array parameters
6.11 Scope of variable/method definitions
6.12 Method name overloading
6.13 Parameter error checking
6.14 Using Scanner in methods
6.15 Perfect size arrays
6.16 Oversize arrays
6.17 Methods with oversize arrays
6.18 Comparing perfect size and oversize arrays
6.19 Using references in methods
6.20 Returning arrays from methods
6.21 Common errors: Methods and arrays
6.22 Java documentation for methods
6.23 Java example: Salary calculation with methods
6.24 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.4 Mutators, accessors, and private helpers
7.5 Initialization and constructors
7.6 Choosing classes to create
7.7 Defining main() in a programmer-defined class
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 Wrapper class conversions
7.14 ArrayList
7.15 Classes and ArrayLists
7.16 ArrayList ADT
7.17 Java documentation for classes
7.18 Parameters of reference types
7.19 Static fields and methods
7.20 Using packages
7.21 Java example: Salary calculation with classes
7.22 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 Output and input streams
9.2 Output formatting
9.3 Streams using Strings
9.4 File input
9.5 File 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 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 overriding class methods
10.13 Java example: Employees and instantiating from an abstract class
11. Recursion
11.1 Recursion: Introduction
11.2 Recursive methods
11.3 Recursive algorithm: Search
11.4 Adding output statements for debugging
11.5 Creating a recursive method
11.6 Recursive math methods
11.7 Recursive exploration of all possibilities
11.8 Stack overflow
11.9 Java example: Recursively output permutations
12. Exceptions
12.1 Handling exceptions
12.2 Throwing exceptions
12.3 Exception with files
12.4 Exceptions with methods
12.5 User-defined exceptions
12.6 Java example: Generate number format exception
13. Generics
13.1 Generic methods
13.2 Generic methods and type bounds
13.3 Generic classes
13.4 Generic classes with type bounds
13.5 Comparable Interface: Sorting an ArrayList
13.6 Java example: Map values using a generic method
14. Collections
14.1 Enhanced for loop
14.2 List: LinkedList
14.3 Map: HashMap
14.4 Set: HashSet
14.5 Queue interface
14.6 Deque interface
15. GUI
15.1 Basic graphics
15.2 Introduction to graphical user interfaces
15.3 Positioning GUI components using a GridBagLayout
15.4 GUI input and ActionListeners
15.5 GUI input with formatted text fields
15.6 GUI input with JSpinners
15.7 Displaying multi-line text in a JTextArea
15.8 Using tables in GUIs
15.9 Using sliders in GUIs
15.10 GUI tables, fields, and buttons: A seat reservation example
15.11 Reading files with a GUI
16. JavaFX
16.1 Introduction to graphical user interfaces with JavaFX
16.2 Positioning GUI components using a GridPane
16.3 Input and event handlers
16.4 Basic graphics with JavaFX
17. Searching and Sorting Alg.
17.1 Searching and algorithms
17.2 Binary search
17.3 O notation
17.4 Algorithm analysis
17.5 Sorting: Introduction
17.6 Selection sort
17.7 Insertion sort
17.8 Quicksort
17.9 Merge sort
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: Abbreviation decoder
18.9 Additional practice: Dice statistics
18.10 zyBooks built-in programming window
Teach Java with this hands-on, interactive zyBook, now updated with advanced zyLabs
Programming in Java is a comprehensive introduction to the principles and practice of Java programming, based on the latest standards.
- Covers foundational constructs, like branches, loops, and functions, and advanced topics, like inheritance, exceptions, and plotting
- Packed with over 600 interactive coding exercises and learning activities to help students master the material
- Customizable so instructors can reorganize, edit, and add their own learning content
- Adopters have access to a test bank with over 600 questions
What is a zyBook?
Programming in Java is a web-native, interactive zyBook that helps students visualize concepts to learn faster and more effectively than with a traditional textbook. (Check out our research.)
Since 2012, over 1,700 academic insitutions have adopted digital zyBooks to transform their STEM education.
zyBooks programming environment
See the advanced zyLabs capabilities:
Authors
Roman Lysecky
Professor Emeritus of Electrical and Computer Engineering, Univ. of Arizona
Adrian Lizarraga
Electrical and Computer Engineering PhD, Univ. of Arizona / zyBooks