Statement type I don't recognize

In the "Object Ordering" section of the Collections trail in the tutorial, an example is provided:

import java.util.*;

public class EmpSort {

static final Comparator<Employee> SENIORITY_ORDER =

new Comparator<Employee>() {

public int compare(Employee e1, Employee e2) {

return e2.hireDate().compareTo(e1.hireDate());

}

};

// Employee database

static final Collection<Employee> employees = ... ;

public static void main(String[] args) {

List<Employee>e = new ArrayList<Employee>(employees);

Collections.sort(e, SENIORITY_ORDER);

System.out.println(e);

}

}

I'm confused about what this part means:

static final Comparator<Employee> SENIORITY_ORDER =

new Comparator<Employee>() {

public int compare(Employee e1, Employee e2) {

return e2.hireDate().compareTo(e1.hireDate());

}

};

Can anyone tell me what this code section is doing? I have looked back through more basic sections of the tutorial, and I haven't found anything that explains what this is, or what I should expect it to do.

Thanks in advance.

[1205 byte] By [sourceLakeJakea] at [2007-11-27 5:56:02]
# 1
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Comparator.html
filestreama at 2007-7-12 16:25:47 > top of Java-index,Java Essentials,New To Java...
# 2

static final Comparator<Employee> SENIORITY_ORDER = new Comparator<Employee>() {

public int compare(Employee e1, Employee e2) {

return e2.hireDate().compareTo(e1.hireDate());

}

};

If you're reading the collections trail, I'll assume you know what final and static mean.

This code defines SENIORITY_ORDER to be an Employee Comparator that orders Employee by reverse order of hire date.

Hippolytea at 2007-7-12 16:25:47 > top of Java-index,Java Essentials,New To Java...
# 3

OK, That much I understand from reading the paragraph text... and maybe I'm missing something really simple, (and perhaps I should have been more clear when I first posted), but the part that I'm not familiar with is the open brace { following the declaration creating the SENIORITY_ORDER instance, followed by the }; terminator.

sourceLakeJakea at 2007-7-12 16:25:47 > top of Java-index,Java Essentials,New To Java...
# 4

Elementary, Jakers, that's the instantiation of an anonymous inner class:

http://java.sun.com/docs/books/tutorial/uiswing/events/generalrules.html#innerClasses

The syntax is:

...new InterfaceName() { /* class body */ }...

or

... new BaseClassName(constructor-args) { /* class body */ }...

Hippolytea at 2007-7-12 16:25:47 > top of Java-index,Java Essentials,New To Java...
# 5
Ok thanks! I haven't been through that trail yet, but that makes sense now. Thanks for the help.
sourceLakeJakea at 2007-7-12 16:25:47 > top of Java-index,Java Essentials,New To Java...