added an example of anonymous class and lambda expression (#13241)

Co-authored-by: Vartika_Nigam <[email protected]>
This commit is contained in:
Vartika Nigam
2023-01-11 10:26:58 +01:00
committed by GitHub
co-authored by Vartika_Nigam
parent 5825cf4775
commit dcbb336236
2 changed files with 22 additions and 0 deletions
@@ -0,0 +1,13 @@
package com.baeldung.anonymousclass;
public class AnonymousClassExample{
public static void main(String[] args){
Thread t1 = new Thread(new Runnable(){
@Override
public void run() {
System.out.println("Thread: "+Thread.currentThread().getName()+" started");
}
});
}
}
@@ -0,0 +1,9 @@
package com.baeldung.lambdaexpression;
public class LambdaExpressionExample{
public static void main(String[] args){
Thread t1 = new Thread(()->System.out.println("Thread: "+Thread.currentThread().getName()+" started"));
t1.start();
}
}