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

Co-authored-by: Vartika_Nigam <Vartika_Nigam@DellTeam.com>
This commit is contained in:
Vartika Nigam 2023-01-11 14:56:58 +05:30 committed by GitHub
parent 5825cf4775
commit dcbb336236
2 changed files with 22 additions and 0 deletions

View File

@ -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");
}
});
}
}

View File

@ -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();
}
}