Created
September 11, 2021 12:12
-
-
Save adityachaudhari/a05cd1c5cc2d07d808c87715b5402978 to your computer and use it in GitHub Desktop.
LambdaExpressionVsAnonymousInnerClass
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
package com.java8.anonymousvslambda; | |
public class LambdaExpressionVsAnonymousInnerClass { | |
public static void main(String[] args) { | |
// anonymous inner class | |
Runnable runnableAnonymous = new Runnable() { | |
@Override | |
public void run() { | |
System.out.println("From Anonymous inner class"); | |
} | |
}; | |
// lambda expression | |
Runnable runnableLamdba = () -> { | |
System.out.println("From lamdba expression"); | |
}; | |
new Thread(runnableAnonymous).start(); | |
new Thread(runnableLamdba).start(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment