My book asks me to write a Javadoc comment for a section of code. For the most part I understand how to do javadocs, but I do not understand what the program is doing.
"Write a Javadoc comment for the following method of a class Person. Assume that class Person has two String data fields lastName and firstName with the obvious meaning. Provide preconditions and postconditions if needed."
public int compareTo(Person per) {
if (lastName.equals(per.lastName))
return firstName.compareTo(per.firstName);
else
return lastName.compareTo(per.lastName);
}
/**
* Method to return?
*
* @param compare the firstName lexicographically
* @param compare the lastName lexicographically
*/
I actually have no idea what this is doing. Is it returning a number? I looked at examples on
http://www.tutorialspoint.com/java/java_string_compareto.htm