내부클래스와 람다식2

さようなら。冬·2020년 12월 12일
0
post-custom-banner
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

@FunctionalInterface
interface MathInterface {
	int cal(int a, int b);
}

class MathClass implements MathInterface {
	@Override
	public int cal(int a, int b) {
		return a/b;
	}
}
public class innerClassExample {

	public static int test(MathInterface mathInterface) {
		return mathInterface.cal(4, 5);
	}

	public static void main(String args[]) {
		MathInterface mathInterface  = new MathClass() 
		{
			
			@Override
			public int cal(int a, int b) {
				System.out.println("run implments[Not] lamdaType");
				return a + b;
			}
		};
		int result = test(mathInterface);
		System.out.println(result);
	
 
	   MathInterface mathInterface1 = (a,b)->{return a*b;};	
	   int AA = mathInterface1.cal(1, 2);
	   System.out.println("결과값은 "+AA);
	}

}
post-custom-banner

0개의 댓글