August 2018
Intermediate to advanced
524 pages
14h 45m
English
Implementing these methods is fairly simple. As this is a very common task, the IDEs support the generation of these methods. These methods are tied together so much that the menu items in the IDEs are not separate; they allow you to generate these methods at once.
Asking the IDE to generate the equals() method will result in something like the following code:
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; MyObjectJava7 that = (MyObjectJava7) o; return Objects.equals(field1, that.field1) && Objects.equals(field2, that.field2) && Objects.equals(field3, that.field3); }
For this sample, we have three Object fields named ...