A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Joined: Jul 10, 2003
Jul 20, 2005 12:20:00
How do I stuff all the elements of a double array into a Collection and then sort them, in Java 1.5
The following throws a runtime class cast exception...
List mList = new
author and iconoclast
Joined: Jul 08, 2003
Jul 20, 2005 12:36:00
Indeed. Why not use the static sort() methods in the
[Jess in Action]
Joined: Dec 06, 2001
Jul 20, 2005 21:28:00
First, I'd like to say that Ernest's suggestion is the best since you don't have to create any extra objects. With that said, I'm surprised that your code compiles! Collections.sort() takes a List argument not an array. You can fix this by doing
Java API Documentation
The Java Tutorial
Joined: Feb 05, 2001
Jul 21, 2005 09:49:00
Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy
I am assuming here, but V Bose is very close to Verbose, that is why I believe that this might not be your real name.
You can change it
Thanks! and welcome to the JavaRanch!
Perfect World Programming, LLC
Two Laptop Bag
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: ArrayList question
Im having problems with writing this program :(
Calculate the average of an ArrayList
Usage of wildcard?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014