Java toString for debugging or practical logical purposes
This may be a very basic question. If you have raised this question, please apologize
The reason I asked is that I have a bunch of classes in Web services that depend on toString () to work properly. In my opinion, things like asstring () will be safer
thank you
Solution
With a few exceptions, toString should be used for debugging, not for production data streams
This method has some limitations that make it less suitable for use in production data streams:
>Without parameters, this method does not allow you to easily change the string representation in response to the environment In particular, it is difficult to format strings in a way that is sensitive to the current locale. > As Java Part of the object class. This method is usually overridden by subclasses This can be harmful in situations that rely on specific representations, because the subclass writer may not know your limitations
The obvious exception to this rule is the toString method of StringBuilder and StringBuffer classes, because these two methods only generate immutable strings from the variable contents of the corresponding objects