Regarding development of comparator
<p>I have a Query I have developed a pojo ..</p>

<pre><code>public class Customer {
int Age;
public Customer(int age, String surname, String forename) {
    super();
    Age = age;
    Surname = surname;
    Forename = forename;
}


String Surname,Forename;

public int  getAge() {
    // TODO Auto-generated method stub
    return Age;
}

public String getSurname() {
    // TODO Auto-generated method stub
    return Surname;
}


public String getForename() {
    // TODO Auto-generated method stub
    return Surname;
}



 public void display()
 {
  // System.out.println(Forename+"\t"+Surname+"\t"+Age);
     System.out.println(Age+"\t"+Forename+"\t"+Surname);
  }
</code></pre>

<p>}</p>

<p>and here is my collection class ..</p>

<pre><code>    class testCustomerComparator
{

    public static void main(String... a)
    {

            Customer customerFirst = new Customer(46,"Alabama", "Christonson");
        Customer customerSecond = new Customer(21, "Anna", "Sobek");
        Customer customerThird = new Customer(27, "Rafael", "Sobek");

        List&lt;Customer&gt; list = new ArrayList&lt;Customer&gt;();
        list.add(customerThird);
        list.add(customerSecond);
        list.add(customerFirst);
}
}
</code></pre>

<p>please advise me How to make comprator for this class , I want to make comparator so  that  a list of customers get  sorted  by age and second by surname. After that you want to sort by forename. please advise I have nesting condition inside comparator</p>

<p>lOGIC MUST BE SOMETHING LIKE...</p>

<pre><code>   public class CustomerComparator implements Comparator&lt;Customer&gt; {

  @Override
  public int compare(Customer c1, Customer c2) {

    if (c1.getAge() == c2.getAge()) {
      if (c1.getSurname().compareTo(c2.getSurname()) == 0) {
          return c1.getForename().compareTo(c2.getForename()) {
      } else {
          return c1.getSurname().compareTo(c2.getSurname());
      }
    } else if (c1.getAge() &gt; b2.getAge()) {
        return -1;
    } else {
        return 1;
    }
  }
</code></pre>

<p>but it is not working please advise</p>
