Re: Object array toString();
In summary, why won't data[i].x.toString(); work?
Re: Object array toString();
Hi sethe23,
Can you please explain exactly what you are trying to output from the toString() method. The complete code woud also help to troubleshoot.
Assuming data[i].x is a String then calling the toString() method explicitly is redundant.
If you are attempting to display some or all the attributes of the data[i] object you will need to override the toString() method.
Regards.
Re: Object array toString();
2 strings and a double. Basically, its a string giving the name, date, and a double value.
Re: Object array toString();
If its the three parameters you want to print out then you will need to ensure the variables within the object are being updated with the values passed in the Constructor's signature. You will then need to override the toString() method of the Name class.
From here you will need to call the toString() method from data[i] instead of data[i].x as you have been.
Regards.
Re: Object array toString();
So data[i].toString (); I believe I tried and got an error.
Re: Object array toString();
Post the complete exception, including stack trace, and the relevant area of code it is thrown from.
Re: Object array toString();
Did you override the method?
Re: Object array toString();
Well its not a runtime error, but it displays name@ and a hex reference
Re: Object array toString();
Then you haven't written a toString() method.
That's not an error, that's the default toString() at work.
<Classname>@<address>
Re: Object array toString();
Ouch, so what am I missing from this?
Re: Object array toString();
Apart from a toString() method on whatever class you have in your array?
Can't tell, as you've not posted much relevant code as far as I can see.
Re: Object array toString();
Ok, I will post it entirely when I get home.