The moose likes Beginning Java and the fly likes toString() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "toString()" Watch "toString()" New topic


kieran pattni
Ranch Hand

Joined: Jan 19, 2004
Posts: 47
hi...anyone help...i type this code out and i get DVD@111f71 instead of
Star Wars...
code below
public class ToStringTest
public static void main(String[]args)
DVD d = new DVD("Star Wars",120);
method from the parent class
public String toString()
//new implementation
return(this.title+" "+this.length);
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
It works OK with this

perhaps you should copy/paste your code, and the error might be spotted.
Davy Kelly
Ranch Hand

Joined: Jan 12, 2004
Posts: 384
hey Kieran,
welcome to the ranch, You will get lots of help here, but a wee suggestion, this makes it easier for people to read you code;
use the code button below the add reply button, and place your code between this, then it looks more like code with the indentation.
also, most people might not know what you are doing, so adding most of the code might help others to help you.
Are you trying to change the public void printOut() method to you own toString() method?
[ February 26, 2004: Message edited by: Davy Kelly ]

How simple does it have to be???
I agree. Here's the link:
subject: toString()
It's not a secret anymore!