Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Better way to print arrays?(print arrays better)
Better way to print arrays? [message #1691038] Wed, 01 April 2015 19:12 Go to next message
Norman Noobie is currently offline Norman NoobieFriend
Messages: 7
Registered: April 2015
Junior Member
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 05:26 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
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
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Better way to print arrays? [message #1691280 is a reply to message #1691038] Sat, 04 April 2015 12:44 Go to previous messageGo to next message
Robert White is currently offline Robert WhiteFriend
Messages: 3
Registered: April 2015
Junior Member
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 20:40 Go to previous messageGo to next message
Norman Noobie is currently offline Norman NoobieFriend
Messages: 7
Registered: April 2015
Junior Member
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] Tue, 07 April 2015 01:37 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

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 21:37 Go to previous messageGo to next message
Norman Noobie is currently offline Norman NoobieFriend
Messages: 7
Registered: April 2015
Junior Member
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 21:54]

Report message to a moderator

Re: Better way to print arrays? [message #1691681 is a reply to message #1691670] Thu, 09 April 2015 03:09 Go to previous messageGo to next message
Andrew Mazar is currently offline Andrew MazarFriend
Messages: 6
Registered: April 2015
Junior Member
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: Thu, 09 April 2015 03:10]

Report message to a moderator

Re: Better way to print arrays? [message #1691687 is a reply to message #1691681] Thu, 09 April 2015 05:10 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

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


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: Better way to print arrays? [message #1691812 is a reply to message #1691687] Thu, 09 April 2015 20:39 Go to previous message
Norman Noobie is currently offline Norman NoobieFriend
Messages: 7
Registered: April 2015
Junior Member
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: Fri Apr 26 23:39:45 GMT 2024

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

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

Back to the top