This content has been marked as final. Show 5 replies
1. create a simple class which can hold the two numbers
2. implement Comparable on this class
3. stick these objects in an ArrayList
Being a novice to both JSPs AND Java is a big problem by the way. I wouldn't touch web development until you've spent a little more time studying core Java; the language, the tools and the platform. Its already difficult enough when you don't try to run before you can walk.
The language also lets you use 2-dimensional arrays, but it's less robust & more error-prone than the other suggestion about a class to hold the two numbers. I invented such a class for my own use a long time ago. Being a very creative person, I named it Pair. Declared it as public class Pair<F, S> so it could hold two of anything. And, wonder of wonders, I also have a class called Triplet !
[Sorry, this was intended as a reply to OP.]
aksarben wrote:This is indeed a good approach.
Being a very creative person, I named it Pair. Declared it as public class Pair<F, S> so it could hold two of anything.
But keep in mind that you cannot parameterize your type with primitives (<tt>new Pair<int,long>(1,3)</tt>). Autoboxing my be your friend then (<tt>new Pair<Integer,Long>(1,3)</tt>) but you'll have to remember that when facing memory issues...