+ 1
What is toString method in java
plz help to understand the difference between a construct and toString in java
1 Answer
0
Do you mean constructor?
The toString method just outputs a string based on the object you call the method on. By default this is the class name followed by the hexidecimal memory address. It is useful to override toString for each object so that you can get information easily when debugging or printing to the console.
If you did mean constructor, that's a special class member that creates an object, and can initialise fields and run code whenever an object of that type is created