This is the compareTo
method of a class implementing the Comparable
(see https://docs.oracle.com/javase/7/docs/api/java/lang/Comparable.html) interface. The return value of compareTo
is defined to be 0
if the objects are identical, < 0
if the argument is lexicographically greater, and > 0
if the argument is less.
The result of the comparison of the Name
object you have here is delegated to the compareTo
method of the familyName
attribute. That means the familyName
attribute of the current Name
object is compared to the argument's familyName
attribute. The second compareTo
check is only done if the familyName
attributes of both Name
object instances are identical. If that's the case, the firstName
is compared instead.