Last active
July 3, 2019 05:47
-
-
Save dhemery/16dcedfb991381531fde3c72c33d7558 to your computer and use it in GitHub Desktop.
Demonstrate that the runtime type of a lambda expression depends on the order of execution of lambda expressions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Run this first with no args, then with 1 or more args | |
public class LambdaExample { | |
public static void main(String[] args) { | |
if(args.length > 0) { | |
lambdaA(); | |
lambdaB(); | |
} else { | |
lambdaB(); | |
lambdaA(); | |
} | |
} | |
private static void lambdaA() { | |
Runnable runnable = () -> {}; | |
System.out.println("Lambda A class name: " + runnable.getClass().getName()); | |
} | |
private static void lambdaB() { | |
Runnable runnable = () -> {}; | |
System.out.println("Lambda B class name: " + runnable.getClass().getName()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Lambda A class name: LambdaExample$$Lambda$168/0x000000080019e440 | |
Lambda B class name: LambdaExample$$Lambda$169/0x000000080019a440 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Lambda B class name: LambdaExample$$Lambda$168/0x000000080019e440 | |
Lambda A class name: LambdaExample$$Lambda$169/0x000000080019a440 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment