added an example of anonymous class and lambda expression (#13241)
Co-authored-by: Vartika_Nigam <Vartika_Nigam@DellTeam.com>
This commit is contained in:
parent
5825cf4775
commit
dcbb336236
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue