Bug 741 : Book p. 309, 310 - Code errors
Last modified: 2008-10-21 23:19




Status:
ASSIGNED
Resolution:
-
Priority:
P2
Severity:
normal

 

Reporter:
hcgilje
Assigned To:
REAS

Attachment Type Created Size Actions

Description:   Opened: 2008-03-05 12:43
processing 0135 on os 10.5, macbook pro
This is partly related to the processing book, but seems to be a general issue.

If I run this simple code:
String[] brees={ "OH ", "NY ", "CA "};
print(brees);

I would expect to get OH NY CA

What I do get is [Ljava.lang.String;@10be08

the only way to print a string array it seems, is to use println.
so
String[] brees={ "OH ", "NY ", "CA "};
println(brees);

gives

[0] "OH "
[1] "NY "
[2] "CA "

I donĀ“t know if this is an error, but at least it behaves differently than
described in the online reference and in the book examples
Additional Comment #1 From fry 2008-03-05 13:11
yes, just as it says in the reference:
http://processing.org/reference/print_.html

does it say otherwise in the book?

there's no sensible way to do a print() of an array, because there are too
many possibilities for how to separate the data. if you want an array on a
single line, use join(), which will let you choose any delimiter you'd like
(spaces, commas, etc) and print() the result of that.
Additional Comment #2 From fry 2008-03-05 13:46
answer was:

//

in the book in example 33-17:
String [] trees = { "ash", "oak"};
print(trees);

and further on in the code.

same in 33-18, 33-20

//

bummer.. we'll need to fix this for the next printing of the book.
Additional Comment #3 From REAS 2008-08-12 23:45
print() does not work with String[] arrays
Additional Comment #4 From REAS 2008-08-28 18:37
We tried to fix this for the 3rd printing, but it was typeset incorrectly.
Examples 33-17 and 33-18 on page 309 needs to be re-formatted. But the
original problem is fixed.

Additional Comment #5 From REAS 2008-10-21 23:19
*** Bug 975 has been marked as a duplicate of this bug. ***
This bug is now being tracked here.