compare 2 objects using compareto() in java example Example: how to compare objects in java this.equals(other)