October 2019
Intermediate to advanced
434 pages
11h 54m
English
A data class will also generate an implementation of toString() if one is not already provided. Once again, the following code shows the generated toString() method for our Article class:
public final class Article { ... @NotNull public String toString() { return "Article(title=" + this.title + ", author=" + this.author + ")"; }}
This is useful for debugging or output, but if you require all properties to be included, you will have to ensure that all properties are present in the primary constructor or override toString() on your own.
Read now
Unlock full access