I have 1 class as mentioned below:
public class mathAdd {
public int add(int val1,int val2) {
int res = 0;
res = val1+val2;
return res;
}
}
I want to pass the method "add" as a parameter something like the way shown in the code below?
public class test4 {
public static void main(String[] args) {
test4 t4 = new test4();
mathAdd m1 = new mathAdd();
t4.testMeth(m1.add);
}
public void testMeth(Object obj.meth()) {
}
}
Is it possible to do this?? if yes how will I achieve this