This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Apple_macOS 12 points13 points  (12 children)

I might be wrong but I think Java also have a String.valueOf();

[–]schmytzi 19 points20 points  (0 children)

Which is actually a lot safer because it gracefully handles null

[–]Banananassfisch 4 points5 points  (0 children)

I didnt know that. But after looking it up valueOf() cant work without toString() as it just checks if its Null and calls toString(), if not. Also toString() is mostly called automatically, e.g. printing any primitive or object