how to compare objects in java with two ways code example Example: how to compare objects in java this.equals(other)