In xcode during debugging, it is possible to print out the value of a variable at that particular stage. I was just wondering if there is a similar function in Netbeans? If not, what Java IDE does?
Generally, the pane underneath the code has some tabs - and one of them will say 'Variables'. Click on that tab and you will see variables and their values. You need to be actually running a debug session before the variables tab is available.
Hover over a variable to see its value. When stopped in the debugger hover the mouse cursor over the variable you want to look at. The DataTip will appear showing you the value of that variable. If the variable is an object, you can expand the object by clicking on the arrow to see the elements of that object.
Click on the "Watches" tab at the bottom. Now click on Run > New Watch at the top menu. Type in "name" to watch the name variable and press the OK button. After pressing enter you will notice that the name variable is in the Watches window.
Have you tried the following methods:
Put a breakpoint on the line where you want to see the value. Run the debugger on that file and switch to the 'Variables' tab (Window > Debugger > Variables
). This will display the values of your variables at that breakpoint. These rows might also have children rows - eg. If there was an array named myArray
, you can click on the +
symbol next to it to see each elements value.
You can also evaluate conditionals by going 'Debug' > 'Evaluate Expression'
. For example, in the iterating loop over 'myArray', you could enter myArray[2] == 5
and click the green ->
arrow to evaluate this. If the value of that element was 5, this would indicate the expression, type (boolean
in this example), and output of that test.
OR
Insert your breakpoint wherever you'd like to monitor the variable.
Right-click the breakpoint and select 'Breakpoint > Properties'.
Set the suspend to "No thread (continue)".
Then just fill in the corresponding field with the format of {=<variable name>}
. So, for example entering: "myVar value @ L30 is: {=myVar}
" will output "myVar value @ L30 is: 1
" to the debugger console.
You shouldn't need to recompile. Just run under the debugger and switch to the console output.
Set breakpoint and use the 'PO' keyword to print the variable.
ex: `NSString *string=@"String to print";` in your code
if want to print this string in debugging mode, just you need to put breakpoint in front of this line and type Po string
in log panel.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With