could anybody Explain The toString() coding..

Recommended Answers

All 2 Replies

As in? What exactly do you want to know?

toString is a method of Object. Object is implicitly extended (somewhere in the hierarchy chain) by every Class. So, every Class has a toString method. Usually it prints some standard String derived from Objects toString method (see the API docs to find out exactly what that is). If you want to see something else, then you need to override the toString method in your class. toString is called implicitly whenever you do a String concatenation with an Object (i.e. use "string" "+" "object") and whenever you call String.valueOf(someObject).

What do you want to do?

- Use the toString() method of an existing class
- Write your own toString() method for a class of your own

?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.