람다식 기초2
interface My{
public void a(int a,int b);
}
public static void main(String[] args) throws Exception {
My m=(x,y)->{System.out.println(x+y);};
m.a(10,20);
}
—> 30 이 출력됨
——————————————————————————–
public static void main(String[] args) throws Exception {
System.out.println(“1.익명의 클래스”);
new Thread(){
public void run(){
try{
Thread.sleep(1000);
System.out.println(“1시간:”+System.currentTimeMillis());
}catch(Exception ex){}
}
}.start();
///////////////////////////////////////////
System.out.println(“2.람다식 표현”);
new Thread(()->{
try{
System.out.println(“2시간:”+System.currentTimeMillis());
}catch(Exception ex){}
}).start();
}