Ernest Friedman-Hill wrote:Hi Steve,
If possible, I'd let the database do the work for you. Add an "ORDER BY ... DESC" clause to do the sorting, and a "LIMIT 8" clause to just grab the top 8 items.
The item list is built on the fly. I have one file with a list of generic codes. I iterate through the list finding matches and getting a count from second file field where the code(s) are located.
What java.util.Comparator implementation should I use? I keep getting ClassCastException by just using Arrays.sort(this.defectcodearray);
Steve Dyke wrote:
What java.util.Comparator implementation should I use? I keep getting ClassCastException by just using Arrays.sort(this.defectcodearray);
Ernest Friedman-Hill wrote:and a "LIMIT 8" clause to just grab the top 8 items.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Steve Dyke wrote:Sorry for asking so many questions.
Do I put this compare class inside my class that I ma building the array in. Also what goes in the <String[]> part of the class?
I am want the defectcodearray[][0] elements sorted
Rob Prime wrote:
Ernest Friedman-Hill wrote:and a "LIMIT 8" clause to just grab the top 8 items.
Be careful with that - it's a MySQL only technique. MS SQL Server for instance uses a TOP X directly after the SELECT keyword:
Ernest Friedman-Hill wrote:
Steve Dyke wrote:Sorry for asking so many questions.
No problem about all the questions -- happy to help.
or you could even nest it inside the other class, if you wanted. Doesn't matter.
Sounds like maybe I'm getting a little ahead of you here; sorry. So you just need to do something like
I would really rather use your, embed in my existing class, suggestion. However, I feel like the code for the class will be different and I cannot figure out how to add the to my class in its current form. When I just copy the code in I get the following
Class must implement the inherited abstract method Comparator.compare(Object, Object)
Thanks again for all the help.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
fred rosenberger wrote:Why do you think something is wrong with that line?
If you are getting a compiler error, please post the full and exact text - it really is useful information.
If there is some other issue, please explain what that is.
Steve Dyke wrote:
Sorry about that.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors