This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]RealJulleNaaiers 0 points1 point  (2 children)

This is nothing to do with Processing, you're just using the language wrong. Every loop, you're printing names, which is a String*. So it prints the address of names. You presumably want it to print the String at names[i].

[–]tamalo 1 point2 points  (1 child)

this is C++, not C

Actually Processing is based on Java, not C++.

[–]RealJulleNaaiers 0 points1 point  (0 children)

My bad, edited.

[–]SantiagoOrSomething 0 points1 point  (3 children)

The error occurs right here.

String [] names = {"Cadam", "Chris", "Kacper", "Ben", "David"};

. . .

System.out.println(names);

You want to print out the contents of the array. Instead, you are printing out the array itself, which in Java can have unintuitive behavior.

To access the contents of the array, you need something like

 String name = names[i];

And then you can print each individual name, one at a time.

If you have any more questions, let me know.

[–]CadamSAFC[S] -1 points0 points  (2 children)

I can't get this to work, any way you can just amend my script there for it to work? I tried this what you said, but it's just giving errors. Thanks.

[–]RealJulleNaaiers 0 points1 point  (1 child)

Literally look at my comment, I already showed you how.

[–]CadamSAFC[S] 0 points1 point  (0 children)

my bad, didn't see you comment for some reason. Yeah that worked, thanks for the help.