Introduction
This book is a practical guide for learning to write code, using the Java language. It can be used in an introductory Java class (e.g. AP Computer Science), or as a guidebook for self-study. The book is meant to be used as a textbook in the way that students actually use textbooks: as a source of simple examples and exercises. This is definitely not meant to be a Java reference, or complete in any way.
You can think of this book as a phrasebook for the Java language: you will learn some common phrases, but more importantly you need to spend time on the exercises.
The only way to learn to write code is to write code. Each chapter has working code examples that illustrate new syntax or concepts, together with the output from running the code. You will learn much more by struggling with and completing the exercises than by reading the examples.
I emphasize writing unit tests to validate your own code. Writing tests for your own code will give you confidence that your code does what you expect. With the development of generative AI, it is easy to generate code to solve any problem in any programming language, and the code may seem to work. However, it is now even more important for software developers to ensure that code behaves as expected.