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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 3416
    
  12
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: 3416
    
  12
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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Trouble printing objects contents through ArrayList
 
Similar Threads
Using super keyword
Inheritance
Storing objects polymorphically in a Figure array
accessing private variable of another object of same class
Runtime and compile-time ?