Hey, I'm very new to programming and I just recently starting programming using Eclipse and I've having some trouble getting my array to print String as opposed to addresses. I haven't messed around too much with arrays so I think some of you may be able to point out where I went wrong fairly quickly.

I'm making a small text based RPGWhen the player chooses to start the game I have it print out the description of the part of town they're in and the exits they can choose from, however when it prints the result is:

Any help would be highly appreciated. Sorry of the mistake is obvious I'm still a very new programmer.

January 11th, 2011, 10:22 PM

helloworld922

Re: Array problems (printing strings)

You didn't define the toString() method of Exits. Java is using Object's default toString() method, which prints out that stuff.

January 11th, 2011, 10:39 PM

James5955

Re: Array problems (printing strings)

Quote:

Originally Posted by helloworld922

You didn't define the toString() method of Exits. Java is using Object's default toString() method, which prints out that stuff.

What do you mean by that? Care to give an example?

January 12th, 2011, 12:21 AM

helloworld922

Re: Array problems (printing strings)

Code Java:

publicclass Exits
{// ... I left out the rest of the Exits class, but you'd obviously want to keep thatpublicString toString(){return"this is an exit object";// you're actual toString method should return specific information you want in a format you want}}