Equivalent of C# anonymous methods in Java?
Pre Java 8: The closest Java has to delegates are single method interfaces. You could use an anonymous inner class. interface StringFunc { String func(String s); } void doSomething(StringFunc funk) { System.out.println(funk.func(“whatever”)); } doSomething(new StringFunc() { public String func(String s) { return s + “asd”; } }); doSomething(new StringFunc() { public String func(String s) { … Read more