September 2019
Intermediate to advanced
816 pages
18h 47m
English
The toString() method is defined in java.lang.Object, and the JDK comes with a default implementation of it. This default implementation is automatically used for all objects that are the subject of print(), println(), printf(), debugging during development, logging, informative messages in exceptions, and so on.
Unfortunately, the string representation of an object returned by the default implementation is not very informative. For example, let's consider the following User class:
public class User { private final String nickname; private final String password; private final String firstname; private final String lastname; private final String email; private final Date created; // constructor and getters skipped ...