• Post Reply Bookmark Topic Watch Topic
  • New Topic

toString  RSS feed

 
shubham agarwal
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am beginner in java.
i don't know how it works..
main problem is how "public String toString()" affect this program(overriding stuff and all)


 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shubham agarwal wrote:i don't know how it works..

I'm afraid that's not much help.

main problem is how "public String toString()" affect this program(overriding stuff and all)

And that's not much better. Exactly what is it you don't understand? What the method is returning? Which method is getting called?

You need to be more precise.

Winston
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16059
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you print an object with System.out.println(), as you are doing in line 26, then toString() is going to be called on the object to convert it to a String that can be printed.

So: What are you passing to System.out.println() in line 26? What toString() method is going to be called?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!