Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 161
  • Last Modified:

documentation

Hi:
   Is my documentation for the following method correct?import java.util.Comparator;

/**
A class that implemements the Comparator interface for sorting objects.
@author Somebody
@version 1.0
*/
class FullNameComp implements Comparator

{

/**
A method that compares arguments for natural order.
@param obj1 The first object.
@param obj2  The second object.
@return     A negative integer, zero, or a positive integer as this
            object is less than, equal to, or greater than the
            specified object.
*/
public int compare(Object obj1, Object obj2)
{
   PhoneBook people1 = (PhoneBook) obj1;
   PhoneBook people2 = (PhoneBook) obj2;
   return people1.fullName.compareTo(people2.fullName);
}

}

0
LearningJava
Asked:
LearningJava
1 Solution
 
TimYatesCommented:
Looks it :-)

I usually do:

/**
 * A class that implemements the Comparator interface for   sorting objects.
 * @author Somebody
 * @version 1.0
 */
class FullNameComp implements Comparator

{

/**
 * A method that compares arguments for natural order.
 * @param obj1 The first object.
 * @param obj2  The second object.
 * @return     A negative integer, zero, or a positive integer as this
 *             object is less than, equal to, or greater than the
 *             specified object.
 */
public int compare(Object obj1, Object obj2)
{
  PhoneBook people1 = (PhoneBook) obj1;
  PhoneBook people2 = (PhoneBook) obj2;
  return people1.fullName.compareTo(people2.fullName);
}

}

As it makes them stand out a bit more :-)
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now