Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

toString()..help

 
kieran pattni
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
System.out.println(d.toString());
method from the parent class
public String toString()
{
//new implementation
return(this.title+" "+this.length);
}
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works OK with this

perhaps you should copy/paste your code, and the error might be spotted.
 
Davy Kelly
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
Davy
[ February 26, 2004: Message edited by: Davy Kelly ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic