• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dumping arrays in eclipse  RSS feed

 
Jim Venolia
Ranch Hand
Posts: 312
2
Chrome Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Eclipse, is it possible to easily dump a 2d array? My code is misbehavin, and watching it in it's 20x20 glory in real time would be a huge improvement over having the 400 elements printed 1 line at a time.
 
manish ghildiyal
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry but couldn't get what actually you want to acheive?

Manish
 
Jim Venolia
Ranch Hand
Posts: 312
2
Chrome Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an array int[20][20]. My code isn't processing it correctly. Currently the only way to see my array is to look at 400 lines in the variables window. Be nice if I could right click on the array and get a nifty dump of 20 lines with 20 entries in each. They don't even have to line up, I just want to see the entries in a condensed form.

By doing that I can set breakpoints at strategic places and continue, as opposed to single stepping over every instruction and scanning the 400 line list of my array to see what's changed.

 
manish ghildiyal
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand correctly you want to see the values array cells have at specific points in your code.
If that is the case, then just write a small piece of code which iterates through your array and prints
its cell values.As yours is an 'array of arrays' so you need to run two loops, one inside other. And
keep the code inside a method and call that method wherever you want to check the current values in array.
Hope it helps you.

Manish
 
Jim Venolia
Ranch Hand
Posts: 312
2
Chrome Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, I've already written dumpArray(int [][] data). But that means I single step in Eclipse to get close to the problem, then edit my code to dump array, rerun and see where it is, edit my code, etc. I'm better off not using Eclipse, just debug via printfs, which I haven't done in 2 decades now.

I would like to run a block of code and dump my array. Debugging would go a lot faster.

Sounds like it isn't possible tho.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jim Venolia wrote:I have an array int[20][20]. My code isn't processing it correctly. Currently the only way to see my array is to look at 400 lines in the variables window. Be nice if I could right click on the array and get a nifty dump of 20 lines with 20 entries in each. They don't even have to line up, I just want to see the entries in a condensed form.

Well, Arrays.toString() will display the contents of each row as a String, and Arrays.deepToString() will display the whole array, but it'll all be on one line, so it'll just be horizontal instead of vertical. It does have 'bookend' characters as guides though.

You pays yer money, you takes yer choice...

Winston
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create a wrapper which encapsulates the data[][]
Provide all required pass through methods to manipulated the data values
Override toString of this class to return the formatted data (row x column grid)
Use this wrapper instead of the data[][].

Enable a break point. After hitting the break point, if you mouse over this wrapper's instance you should see the formatted out put in the Eclipse style tool tip
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!