Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I monitor the values of variables in a Java program?

Tags:

java

Lets say i have a couple of loops in my Java code. To check my code for correctness, i write all the necessary variables on paper and imagine the code executing in my mind. I note their values with each step on the paper. Sometimes i have to use print statements also to spot errors.

Is there any software (stand alone or plugin for Eclipse IDE which I use) which can track all these things for me ?

like image 919
david blaine Avatar asked Dec 25 '12 06:12

david blaine


2 Answers

This is exactly what the Debugger is for. Resist the urge to write to console or file to track these values.

Spend some time learning how to use the debugger correctly, you're going to spend a lot of time using it in the future.

Note: I think it is very positive that you instinctively came to the conslusion that a tool such as the debugger should exist.

like image 160
Robben_Ford_Fan_boy Avatar answered Oct 12 '22 12:10

Robben_Ford_Fan_boy


See this link if you use Eclipse IDE.

Mostly all IDEs have a built in debugger which allows you to set breakpoints and step through your program line by line, viewing variable values at each step of the way.

like image 22
Matt Clark Avatar answered Oct 12 '22 12:10

Matt Clark