We would like to know how to check the target type of Lambda expression.
public class Main { /*from www.j a v a 2s . com*/ public static void main(String[] args) { A a = () -> { System.out.println("Something"); }; B b = () -> { System.out.println("Something"); }; System.out.println(a.getClass()); System.out.println(b.getClass()); } } interface A { void abstractMethod(); } interface B { void abstractMethod(); }
The code above generates the following result.