Re: Java Arrays.sort throws exception
This is my very first post and I am not up on the etiquete yet.
I realize that the problem must be in my code. Actually, I didn't
right this code, I inherited it. I have a lot of programming
experience but not in this particular environment.
Here, a list is populated in a loop and then Collections.sort is
called on that list. I would like to know what the possible problems
may be, what to look for.
Thanks
On May 14, 2:57 pm, Eric Sosman <Eric.Sos...@sun.com> wrote:
captain wrote:
Eric,
Thank you very much for your response.
My code:
List adminItems = new ArrayList();
loop:
adminItems.add(administeredItem);
Collections.sort(adminItems);
My code:
import java.util.ArrayList;
import java.util.Collections;
public class Foo {
public static void main(String[] unused) {
final int COUNT = 2700;
ArrayList<Integer> list = new ArrayList<=
Integer>(COUNT);
for (int i = 0; i < COUNT; ++i)
list.add(new Integer(
(int)(Math.random() * Integ=
er.MAX_VALUE)));
Collections.sort(list);
}
}
Runs like a champ, both as shown and with COUNT = 1000000.
There's something I'd like you to notice, a difference between
your code and mine: Mine actually runs, while yours won't even
compile. I can get yours to compile and run by "filling in the
blanks," as it were -- but that probably means that the problem is
in the blanks, the part you still haven't revealed.
Hint, hint.
--
Eric.Sos...@sun.com