Better way to print arrays? [message #1691038] |
Wed, 01 April 2015 15:12  |
Eclipse User |
|
|
|
My program has a couple of 30x30 arrays. I'm trying to display them, but it seems the best I can do is get 1 value per line which is less than helpful. Is there a way to just dump the array?
For example, what I want when I use Eclipse to print my array is something like
0: 32 8 16 24 42 0
1: 6 22 33 1 12 21
2: 66 42 12 8 9 17
etc, as opposed to
0:
0: 32
1: 8
2: 16
3: 24
etc
|
|
|
|
|
|
|
Re: Better way to print arrays? [message #1691670 is a reply to message #1691393] |
Wed, 08 April 2015 17:37   |
Eclipse User |
|
|
|
This is a pure Eclipse question, has nothing to do with Java except that I happen to be writing Java.
It would be very helpful to see my data values change as I step through my code, as opposed to stepping over the entire routine and dumping the result to the console.
Right now when I show a boolean array it has the form:
0:
0:true
1:false
2: false
etc for row 0, then
1:
0: false
1: true
etc.
As it's a 30x30 array that's 900 lines to display the array, a royal pain to navigate as I step through the code manipulating that array. Especially as I'm looking for things that change
The other format I've seen is (assuming a 3x3 array) is:
foo [false, false, true][true, false, false][false, false, false]).
The format may be different, I'm not running Eclipse right now, but you get the gist. It's better, but still difficult to navigate.
This question has nothing to do with Java. The program could be C, C++, perl, Python, or whatever. The question is "how do I better display an array while debugging my program?"
[Updated on: Wed, 08 April 2015 17:54] by Moderator
|
|
|
Re: Better way to print arrays? [message #1691681 is a reply to message #1691670] |
Wed, 08 April 2015 23:09   |
Eclipse User |
|
|
|
Norman Noobie wrote on Wed, 08 April 2015 21:37This is a pure Eclipse question, has nothing to do with Java except that I happen to be writing Java.
It would be very helpful to see my data values change as I step through my code, as opposed to stepping over the entire routine and dumping the result to the console.
Right now when I show a boolean array it has the form:
0:
0:true
1:false
2: false
etc for row 0, then
1:
0: false
1: true
etc.
As it's a 30x30 array that's 900 lines to display the array, a royal pain to navigate as I step through the code manipulating that array. Especially as I'm looking for things that change
The other format I've seen is (assuming a 3x3 array) is:
foo [false, false, true][true, false, false][false, false, false]).
The format may be different, I'm not running Eclipse right now, but you get the gist. It's better, but still difficult to navigate.
This question has nothing to do with Java. The program could be C, C++, perl, Python, or whatever. The question is "how do I better display an array while debugging my program?"
One option is to use the debugger.
Add break points and use the debugger tool.
The only other real option is to build a GUI that displays your values in real time.
[Updated on: Wed, 08 April 2015 23:10] by Moderator
|
|
|
|
Re: Better way to print arrays? [message #1691812 is a reply to message #1691687] |
Thu, 09 April 2015 16:39  |
Eclipse User |
|
|
|
Thanks Nitin, that looks like exactly what I need.
Andrew, I would think that by saying as I step through my code one would know that not only was I using the debugger, but that I had used breakpoints to get to the code causing me trouble.
|
|
|
Powered by
FUDForum. Page generated in 0.09397 seconds