Person.CompareByName
Keywords: Person.CompareByName class

| Package
| Class | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

## Class Person.CompareByName

    java.lang.Object
      Person.CompareByName

All Implemented Interfaces:
  java.util.Comparator

Enclosing class:
  Person

public static class Person.CompareByName
extends java.lang.Object
implements java.util.Comparator

Comparator for comparing two persons by alphabetical order of name

Constructor Summary
`Person.CompareByName()`

Method Summary
`int` | `compare(java.lang.Object person1, java.lang.Object person2)` Compare two objects (which must both be Persons) by last name, with ties broken by first name
`boolean` | `equals(java.lang.Object person1, java.lang.Object person2)` Compare two objects (which must both be Persons) by name

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface java.util.Comparator
`equals`

Constructor Detail

### Person.CompareByName

    public Person.CompareByName()

Method Detail

### compare

    public int compare(java.lang.Object person1,
                       java.lang.Object person2)

  Compare two objects (which must both be Persons) by last name, with ties broken by first name

  Specified by:
    `compare` in interface `java.util.Comparator`
  Parameters:
    `person1` - the first object
    `person2` - the second object
  Returns:
    a negative number if person1 belongs before person2 in alphabetical order of name; 0 if they are equal; a positive number if person1 belongs after person2
  Throws:
    `java.lang.ClassCastException` - if either parameter is not a Person object

### equals

    public boolean equals(java.lang.Object person1,
                          java.lang.Object person2)

  Compare two objects (which must both be Persons) by name

  Parameters:
    `person1` - the first object
    `person2` - the second object
  Returns:
    true if they have the same name, false if they do not
  Throws:
    `java.lang.ClassCastException` - if either parameter is not a Person object

| Package
| Class | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD