I want to make a method that does a specific task, but then calls another method with the results of that task. Well easy enough, but the trick is that I want the method (the second one thats getting called by the first one) to be a parameter of the first method.
I probably explained that terribly, so here is what I think it might look like
public static void main(String[] args) {
double[][] data = {
{2,6},
{-32,5}
}
loop(data,{System.out.println(row * col)});
}
public static void loop(double[][] data,somemethod(row,col)) {
for (int row = 0;row < data.length;row++)
for (int col = 0;col < data[0].length;col++)
somemethod(row,col);
}
So the loop method does a task, and then runs the code that was passed as a parameter. Can this be done in java? I feel like I have seen it somewhere.