Why should I implement the toString method for my object?

Aside from the printed materials for the console, what other use have you found for the toString () method for your objects?

+3
source share
3 answers

It makes convenient debugging help when you just want to quickly view the contents of an object.

+5
source

I use it for debugging purposes only . For functional requirements, I always implement a well-named method, for example String toExportFormat().

, , , . toString() - , , . , , . toString() - .

+4

, Swing.

, - , FAR , toString().

+1
source

Source: https://habr.com/ru/post/1744385/


All Articles