• Post Reply Bookmark Topic Watch Topic
  • New Topic

toString()  RSS feed

 
Karthikeyan Pandian
Ranch Hand
Posts: 66
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does toString() belongs to Object or String class..
I read that toString () belongs to object class but in String class also I read about that toString()..
so , I need to clarify with you ppl's
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Karthikeyan Pandian wrote:Does toString() belongs to Object or String class..
I read that toString () belongs to object class but in String class also I read about that toString()..
so , I need to clarify with you ppl's


The JavaDoc is a good place to start ... java.lang.Object and java.lang.String.

Henry
 
Karthikeyan Pandian
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But i cant understand the difference..
i just want to know how the same method under two different class
can be used
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Karthikeyan Pandian wrote:But i cant understand the difference..
i just want to know how the same method under two different class
can be used


Do you know what overriding is? And how it works?


BTW, let's move this topic to the beginners java forum...

Henry
 
Karthikeyan Pandian
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes Mr.henry i know
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:
Karthikeyan Pandian wrote:But i cant understand the difference..
i just want to know how the same method under two different class
can be used


Do you know what overriding is? And how it works?


Karthikeyan Pandian wrote:yes Mr.henry i know



Basically, the String class overrides the toString() method, because the toString() method provided by the Object class isn't suitable. As for how it works and used, well, you already know.

Henry
 
Karthikeyan Pandian
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, Thank you
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!