Currently I have a comparator class in the same file as one of my classes.
public class Tree {
public static Comparator<Tree> TreeSize = new Comparator<Tree>() {
public int compare(Tree t1, Tree t2)
{
etc...
}
}
}
Should the Comparator class be in its own file?
If you happen to have just one comparator, why not just impose a natural ordering by having the class implement
Comparable? Then you can not only keep it at the class level, but you don’t need the second class at all.