debugging
7 tutorials tagged “debugging”.
- Helpful NullPointerException MessagesSince Java 14, a NullPointerException says exactly which reference was null and what Java was trying to do. How to read the messages and get variable names.
- Assertions in JavaCheck your own assumptions with assert: the syntax, why assertions are off unless you pass -ea, and when to use them instead of exceptions.
- Reading a Stack Trace in JavaTurn the scary red error text into a map of the bug: the exception line, the frames from newest to oldest, your code vs library code, and Caused by.
- ArrayIndexOutOfBoundsExceptionThe most common array error: what triggers it, how to read its message, the off-by-one and empty-array cases that cause it, and how to prevent it.
- Common Beginner Compile ErrorsHow to read a javac error message, and how to fix the eight compile errors every beginner meets, from ';' expected to missing return statement.
- Infinite LoopsLoops that never end: the usual causes, how to stop a stuck program, and the intentional while (true) loop with break used in servers and menus.
- Using the DebuggerFind bugs by pausing your program and watching it run: breakpoints, step over, step into, step out, watches and conditional breakpoints, with a real bug to fix.