"But that's not all. "Why do you think debug mode was invented?"

"That was a rhetorical question."

"The most interesting thing is that, while debugging, you can watch the value of every variable at every step! This includes local method variables, arguments, and almost anything really."

"When you reach a breakpoint in debug mode, a special panel appears at the bottom:"

IDEA: watch, quick watch - 1

All of the local variables are visible in the variables section, which is highlighted in green
In the part of the watch window that's highlighted red, you can add variables yourself
The list of threads is highlighted in orange. And directly below that is the current thread's stack trace

"Now I'll press F8 three times, and the values for two new variables (sum5 and sum7) will appear in the middle window."

"In the window on the bottom-right, I'll click the plus sign and add the expression 'sum5+sum7'."

"Take a look at what I got:"

IDEA: watch, quick watch - 2

"In the bottom center, we see the value of the variables"
"On the bottom right, we see the current value of the expression sum5+sum7"

"The Watches window is convenient to use when variables have long and complex names, for example:"


"Cool! Nifty stuff."

"In addition to Watches, there is also Quick Watches. You can learn the value of any variable by simply hovering over it with the mouse. Hold the mouse over the variable for a couple of seconds and a pop-up window will show its value."

IDEA: watch, quick watch - 3

"The mouse cursor isn't visible in the screenshot, but it was in the center of the red circle (right above the variable name)."

"Here's the best part. You can change the value of variables!"

"Just right-click a variable in the Watches or Variables windows, select the set value option, and enter a new value. Or just press F2."

"Here's how it looks for me:"

IDEA: watch, quick watch - 4

"You can set the variable to any value, a reference can be set to null, …"

"Then press Enter and that's it. The variable now has a new value."

"Wow, I didn't know half of this stuff. What a useful lesson."