I recently started learning Java using VS Code and I am trying to configure it to meet my needs. Right now I’m debugging a test program I’m writing where I have an ArrayList
of Integers
, but the issue I’m facing is that the debugger doesn’t show the values of the list directly and it shows instead "Integer@52".
Is there any way to configure VS Code to show the integer value directly without needing to click on each item?
- I tried searching in Google:
java vscode list show values
and
java vscode show list values automatically
- Asked this to ChatGPT:
"I open the list contents in the "Run and Debug" window but the contents are hidden and I need to
click on each individual item to see what value it holds. Instead of showing me the value it shows "Integer@52"
2
Answers
Well, it’s an box object (
Integer
and notint
). It’s not unreasonable for it to be displayed in the debugger accordingly. There are real differences, such as the result of the==
(identity/address comparison) operator.At the time of this writing, I don’t see a setting that sounds related to showing unboxed values of box types in the package.json of the Java debugger extension. Either I’m missing something, or no such feature exists right now.
I tried looking for existing feature-request issue tickets by googling "
site:github.com/microsoft/vscode-java-debug box OR unbox "type"
", but didn’t find anything that looked relevant. You could write a feature-request issue ticket requesting for such a feature. If you do so, please comment here linking to it for posterity.Right click and select
Enable 'toString()' Object View
Then you can see the value directly
Meanwhile, if you want the debugger to automatically expand the value for you instead of manually click the ‘eye’ icon to expand the variable. You can turn on the setting
debug.autoExpandLazyVariables