wood burning stoves 2.0*
The moose likes Java in General and the fly likes Trouble printing objects contents through ArrayList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Trouble printing objects contents through ArrayList" Watch "Trouble printing objects contents through ArrayList" New topic
Author

Trouble printing objects contents through ArrayList

David Laverdy
Greenhorn

Joined: Aug 14, 2011
Posts: 18




I've tried just about everything I know to get the array to NOT print the location of the object and it's contents. I have overridden the toString() method for each object and I still get nothing back. Help is appreciated Thanks
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3489
    
  13
David Laverdy wrote:I have overridden the toString() method for each object

Not in the code you've posted you haven't.


Joanne
David Laverdy
Greenhorn

Joined: Aug 14, 2011
Posts: 18
I thought I did. Shouldnt showData() work ?
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3489
    
  13
David Laverdy wrote:I thought I did. Shouldnt showData() work ?

If you call showData, then that will work, but you are calling toString. An overriding method has to have the same signature (including the name) as the method it is overriding.
David Laverdy
Greenhorn

Joined: Aug 14, 2011
Posts: 18
Thanks I did a toString() method and I got the output I needed thanks!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Trouble printing objects contents through ArrayList