• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dumping arrays in eclipse

 
Ranch Hand
Posts: 574
VI Editor Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry but couldn't get what actually you want to acheive?

Manish
 
Jim Venolia
Ranch Hand
Posts: 574
VI Editor Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 574
VI Editor Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic