Usage
Objects.equal(Object, Object)
Invoking this method then it will avoid the risking of NullPointerException when we need to compare two object whether they equal.
1 | Objects.equal("a", "a"); // return true; |
Objects.hashCode(Object, ....)
Generating hash code with multiple object will be simple. And it also can hash all fields of an Object to get more sensible code value.
1 | // generate hash code with multi object |
ComparisonChain
ComparisonChain is a fluent idiom and much more readable. less prone to accidental typos, and smart enough not to do more work than it must.
It only performs comparisons until it finds a non-zero result, after which it ignores further input.
1 | ObjectsTraining objectsTraining = new ObjectsTraining(); |