How to get output from a function in Java? -


i have main program call function :

public static void eucdist(int i, double data[][], double weight[][]) {      double sum = 0;      double min = 10000;      (int j=0; j<5; j++) {         (int k=0; k<5; k++) {             sum = sum + math.pow((weight[k][j] - data[i][k]),2);         }          double dist = math.sqrt(sum);          if(dist < min) {             min = dist;             int savecol = j;         }     } } 

how can savecol in main program?

if put

public int getsavecol(){     return savecol; } 

so can call savecol eucdist.savecol returns error.

you return it:

public static int eucdist(int i, double data[][], double weight[][]) {      double sum = 0;      double min = 10000;     int savecol = -1;      (int j=0; j<5; j++) {         (int k=0; k<5; k++) {             sum = sum + math.pow((weight[k][j] - data[i][k]),2);         }          double dist = math.sqrt(sum);          if(dist < min) {             min = dist;             savecol = j;         }     }     return savecol; } 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -