How to print variable value during debugging in Netbeans?

In xcode, during debugging, you can print the value of a variable at this stage. I'm just wondering if there is a similar feature in Netbeans? If not, what does the Java IDE do?

+7
variables debugging xcode netbeans
source share
2 answers

Have you tried the following methods:

Place a breakpoint on the line where you want to see the value. Run the debugger in this file and go to the "Variables" tab ( Window > Debugger > Variables ). This displays the values โ€‹โ€‹of your variables at this breakpoint. These lines can also have child lines - for example. If there was an array named myArray , you can click on the + icon next to it to see each element value.

You can also evaluate conditional expressions by going to 'Debug' > 'Evaluate Expression' . For example, in an iteration loop over "myArray" you can enter myArray[2] == 5 and click the green arrow -> to evaluate it. If the value of this element is 5, this indicates an expression, a type ( boolean in this example), and the output of this test.

OR

  • Insert a breakpoint wherever you want to control the variable.

  • Right-click the breakpoint and select Breakpoint Properties.

  • Set the pause to โ€œNo thread (continued).โ€

  • Then simply fill in the appropriate field with the format {=<variable name>} . So, for example, input: " myVar value @ L30 is: {=myVar} " will output " myVar value @ L30 is: 1 " to the debugger console.

You do not need to recompile. Just run under the debugger and switch to console output.

+4
source share

Set a breakpoint and use the keyword "PO" to print the variable.

 ex: `NSString * string=@ "String to print";` in your code 

if you want to print this line in debug mode, you just need to put a breakpoint in front of this line and type Po string in the log panel.

+1
source share

All Articles