Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
157 views
in Technique[技术] by (71.8m points)

java - How to set breakpoints at specific spots in Intellij?

I have a program that modifies images. When I try to compare the results of my program to the expected values the result is pretty much unreadable.enter image description here

This continues for very very long, so how can I make it so that I only see the difference between the expected and actual values, and where these differences are?

And when using the inbuild debugger, for example if I have a loop

 for (int i = 0; i < 100; i++) {
  for (int j = 0; j < 100; j++) {
    do stuff
  }
}

How can I set up a breakpoint so the debugger can tell me the values of things I need to know to find out what the error is:

  1. When i = 99
  2. Right before a discrepancy between the expected and actual value occurs
  3. Right before the program exits to an error such as out of bounds.

Because currently, all I can do set a breakpoint on a specific line, but inside a loop I have to click step over repeatedly rather than skip to where I need in the loop.

question from:https://stackoverflow.com/questions/65851817/how-to-set-breakpoints-at-specific-spots-in-intellij

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

TLDR; right click on a breakpoint and add code that returns a boolean to make it a conditional breakpoint

I think this post useful for your question.

conditional breakpoint in IntelliJ


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...