• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

toSting()

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wanna know about that how the toString() method works. I want the answer with complete detail. And also that how to use this function. waiting or reply from any one.
bye
Noman Iqbal.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well you are going to have a heck of a time getting ANY answer unless you give us some hint about WHAT CLASS you want to know about the toString() method of. There are about 4 zillion classes that have that method, and the answer changes depending on the class.

However as an example:
int i = 1232354345;
String s = Integer.toString(i);
Now s has a string representation of the integer value.
So what class did YOU want to know about?
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Noman,
Since Cindy gave you a great example, I will provide the complete details. Since I tire easily, I will only give details on about 200-300 class (out of Cindy's 4 zillion). Maybe if you keep asking you can start a good collection. If you actually get all 4 zillion you get a new Mercedes (so I heard!).
Complete Details
Happy Reading!
Manfred.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi , Noman
In response to your question i want to go on basics, Every class is extended from Object class implictly , and Object class has toString method so every class has a toString method.
While calling toString method using objects of any class returns String representation of that class.
whenever you print an object on console it's imlicit tostring method is called and returned value of toString method is printed on console.

Hope it will work.
 
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Class Object is the root of the class hierarchy. Every class has Object as a superclass. All objects, including arrays, implement the methods of this class.
The toString() method returns a string representation of the object.
 
Screaming fools! It's nothing more than a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic