View Full Version : fidning highest value of a row in a 2D array

09-26-2008, 07:46 AM
okey, when I have an 2D array like

new double[11][17]
and I insert several values

How can I extract the row from the array with the highest value total?

Yes I am a programmernEWB_bbBB

// peace

09-26-2008, 09:00 AM
Java is not Javascript (http://www.htmlgoodies.com/beyond/javascript/article.php/3470971).

09-26-2008, 01:31 PM
y not create a lil `if` statement below the code the use to insert the new value to the array. this would only check whether or not this value is greater than any of the previous entries. I am not sure how you do this in Java but im sure it wouldn't be to difficult.

In php there are functions to sort array values and i would think that Java would have similar function.

rnd me
09-27-2008, 09:35 AM
fastest way i know:

var r = [

Math.max.apply(1, r[0]) //==5
Math.max.apply(1, r[1]) //==51
Math.max.apply(1, r[2]) //==121