Please help. I am very new to java and trying to build a multidimensional array. I have two variables 1)item_name and 2)item_value. These are values that I obtain by looping through a database result set. I need to build and array that can hold these variables. Once the multidimensional array is built I need to be able to sort it by item value. For example I would like to do something like this: while (rs.next) array.name = item_name array.value = item_value end array.sort(value)
Thanks for any help!
posted 12 years ago
It might be worth considering making a very simple Item object that implements Comparable. All you'll need is getters and setters for the 'value' and 'name' properties and a compareTo method. you can use Arrays.sort() or Collections.sort() depending on what structure you store the Items in. -Tim