Menu

#237 Enhanced array printout [very easy]

open
nobody
5
2004-09-15
2004-09-15
Dan Smith
No

Print array values in the interactions pane as:

[1, 2, 3]

rather than:

[Ljava.lang.Integer;@16b6c55

We already make a check to determine the returned type
of any DynamicJava expression in the interactions pane.
If the returned type is a String, for example, we
output "\"" + result.toString() + "\"". For primitive
types, we add color. Array types are currently treated
like any other non-String reference type -- we output
result.toString(). A simple modification would make
arrays a special case, like Strings and primitives.

As of the 1.5 API, java.util.Arrays includes methods
"toString()" and "deepToString()" that could easily be
used to accomplish this. A simple approach could check
that the 1.5 APIs are available and then call the
appropriate method. Alternately, the *.java file
generated from any *.dj2 file currently contains a
toString() method that works for arrays and without the
1.5 API. It could be lifted almost directly into the
DrJava code base.

Discussion

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.