JAVA/DAY 20 _ 23.09.13

Lambda4_메서드참조

민지짱민지최고 2023. 9. 13. 13:21
interface BBB {
	
	public int some(int a /* int b 이런식으로 달라지면 error난다구 */ );
	
}

 

// 매서드를 넣을수도있다구

BBB t1 = a -> Math.incrementExact(a);		// 그냥 어떤걸넣어본거임
int result = t1.some(5);
System.out.println(result);
// 이렇게 써도 되겠지 --> System.out.println(t1.some(5));

 

// ★★★ 매서드 참조 : 아주아주 요약한.... 매개변수 자체도 없애버렸노;

BBB t2 = Math::incrementExact;
int result2 = t2.some(5);
System.out.println(result2);