Delegate cannot be initialized with static method 'identifier'
The compiler detected a delegate instantiation but the method reference, passed as a parameter, was a static method. When instantiating a delegate, you must pass a non-static method as a parameter. Ensure that the method you are defining the delegate to use is a non-static method and compile again.
The following example illustrates this error:
delegate int MyDelegate (int var1, String var2)throws Exception;
public class Simple{
public static int method1(int var1, String var2) throws Exception{
//do something here
return var1;
}
public static void main (String args[]){
Simple smp = new Simple();
MyDelegate md = new MyDelegate(smp.method1);
/*error: the method passed as a parameter to the delegate is a
static method */
}
}