Skip to main content



      Home
Home » Newcomers » Newcomers » Better way to print arrays?(print arrays better)
Better way to print arrays? [message #1691038] Wed, 01 April 2015 15:12 Go to next message
Eclipse UserFriend
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 #1691067 is a reply to message #1691038] Thu, 02 April 2015 01:26 Go to previous messageGo to next message
Eclipse UserFriend
Norman,

It's best to ask "pure Java" questions somewhere like StackOverflow or
Code Ranch.

On 01/04/2015 10:56 PM, Norman Noobie wrote:
> 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 #1691280 is a reply to message #1691038] Sat, 04 April 2015 08:44 Go to previous messageGo to next message
Eclipse UserFriend
System.out.println(Arrays.toString(your_array)); won't do it ?
Re: Better way to print arrays? [message #1691383 is a reply to message #1691280] Mon, 06 April 2015 16:40 Go to previous messageGo to next message
Eclipse UserFriend
I've already got a routine to print the arrays (although Arrays.toString() looks interesting. What I want is to dump the formatted array from Eclipse itself.

How did you know my code was in Java?
Re: Better way to print arrays? [message #1691393 is a reply to message #1691383] Mon, 06 April 2015 21:37 Go to previous messageGo to next message
Eclipse UserFriend
On 04/06/2015 02:40 PM, Norman Noobie wrote:
> I've already got a routine to print the arrays (although
> Arrays.toString() looks interesting. What I want is to dump the
> formatted array from Eclipse itself.

Eclipse is an integrated development environment to help you write
programs in many languages including and especially Java. What do you
mean by "dump ... from Eclipse itself"? Do you mean dump the array to a
file (since obviously you're already dumping it to the console where you
can see it)?

These are "pure Java" questions and nothing to do with Eclipse at all.
You should ask such questions in other forums like javaranch.com or
stackoverflow.com.
Re: Better way to print arrays? [message #1691670 is a reply to message #1691393] Wed, 08 April 2015 17:37 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
Norman Noobie wrote on Wed, 08 April 2015 21:37
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?"


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 #1691687 is a reply to message #1691681] Thu, 09 April 2015 01:10 Go to previous messageGo to next message
Eclipse UserFriend
You can define a Detail Formatter, although at the scale you're working with, it simply might not be effective.

https://wiki.eclipse.org/Debug/FAQ#What_are_detail_formatters.3F
http://www.robertwloch.net/2012/01/eclipse-tips-tricks-detail-formatter/
http://www.howardism.org/Technical/Eclipse/Eclipse_Detail_Formatter.html
Re: Better way to print arrays? [message #1691812 is a reply to message #1691687] Thu, 09 April 2015 16:39 Go to previous message
Eclipse UserFriend
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.
Previous Topic: How to ignore a folder from the checks during eclipse renaming refactoring?
Next Topic:How Can I Tell if a Plug-In is on my Computer - Thus Available to Eclipse
Goto Forum:
  


Current Time: Tue May 20 21:37:13 EDT 2025

Powered by FUDForum. Page generated in 0.09397 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top