List<Question> questions = new ArrayList<Question>();
questions.addAll(getAllQuestions()); //returns a set of Questions
Collections.sort(questions, new BeanComparator("questionId")); //org.apache.commons.beanutils.BeanComparator
Under Java 1.5, the above works fine except that the 'new BeanComparator("questionId")' generates an unchecked warning. I do not ...
My question is the following,
I have an interface that requires me to return java.util.Comparator <E>, my question is, how can i implement an abstract class that somehow returns a generic Comparator.
...
Should Foo be written like version 1 or version 2 below? What are the considerations for choosing between the two? Are there any upsides or downsides for one or the other? class Foo implements Comparator{ ... public int compare(Object o1, Object o2) { ... } } class Foo implements Comparator{ ... public int compare(Foo foo1, Foo foo2) { ... } } ...
pifpafpuf wrote: Obviously one instance of the comparator per class J would in principle suffice. That's not a reason to use a singleton. There's virtually never a reason to use one, in fact, but in particular only needing a single instance isn't a reason. You'll only need a single instance of a lot of classes. For it to be a candidate ...