Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save adityachaudhari/a05cd1c5cc2d07d808c87715b5402978 to your computer and use it in GitHub Desktop.
Save adityachaudhari/a05cd1c5cc2d07d808c87715b5402978 to your computer and use it in GitHub Desktop.
LambdaExpressionVsAnonymousInnerClass
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