find maximum value from for loop

hello there,

I am new to java language..and i have some trouble in finding maximum value for the output of the calculation from for loop.:confused:

this is my code:

Code:

`import static java.lang.Math.*;`

import java.util.*;

public class sort2

{

public static void main(String arg[])

{

double [] x = new double[10];

double [] y = new double[10];

double [] v = new double[10];

double dx, dy, dv;

double xy, a, vf;

int j;

x[1]= 0; y[1]= 0; v[1]= 15;

x[2]= 0; y[2]= -1; v[2]= 7;

x[3]= 1; y[3]= -1; v[3]= 6;

x[4]= -1; y[4]= 0; v[4]= 8;

x[5]= -1; y[5]= -1; v[5]= 5;

x[6]= 1; y[6]= 0; v[6]= 11;

x[7]= -1; y[7]= 1; v[7]= 8;

x[8]= 0; y[8]= 1; v[8]= 9;

x[9]= 1; y[9]= 1; v[9]= 10;

for(j=2; j<=9; j++){

dx= x[1] - x[j];

dy= y[1] - y[j];

dv= v[1] - v[j];

xy= pow((dx*dx+dy*dy),0.5); // (vx^2 + vy^2) raised to the power of 1/2

vf = dv/xy; }

//here where i am stuck!! how to pick the max value of vf after for loop

//need vf-max for further calculation here!

}

}

actually i am searching for gradient of v which is vf=dv/xy around point (x[1], y[1]).

i used 'for loop' to calculate each gradient vf, and then to find the maximum value of vf without writing it because i am going to used the max vf for further calculation.

Thanks in advance!

napi,