M
M
Mikhri2020-10-31 20:34:12
IDE
Mikhri, 2020-10-31 20:34:12

What means can be used to organize the output of the value of the target elements of the code during step-by-step debugging?

Sometimes, for a better understanding of the algorithm, it would be very convenient to see the state of the element of interest to me (array, variable, etc.) at the current debugging step - so that this does not require additional actions (for example, for Eclipse - move the mouse over this element).

Purely for understanding - let's take something like this and put breakpoints on each line in for.

double [] array = new double [10];	
for (int i = 0; i < array.length; i++) {
    array[i] += i*i;
    if (array[i] % 2 == 0) array [i] = Math.random() + array[i]*array[i];
}


And the task is to see what the array looks like at the current step.

Of course, in this particular case, you can simply print the array to the console on each iteration of the loop by simply adding System.out.println(Arrays.toString(array));

But sometimes it's very inconvenient. Especially if you need to display not one array, but several. Plus a dozen more variables. And this approach turns completely into rubbish, if the target piece of code just has to output something to the console itself - it turns out to be a hard-to-read mess.

Are there any ways to hang all the elements of interest to me somewhere on the second monitor, so that they hang there all the time of debugging and simply reflect the current values, leaving the console free?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question