inblog logo
|
Coding_study
    JAVA

    메소드 참조

    yuzu sim's avatar
    yuzu sim
    Jan 13, 2024
    메소드 참조

    1. 메소드 참조란?

    자바에서 메소드를 간결하게 표현하기 위한 기능 람다 표현식을 더 간결하게 작성할 수 있다.
     
    1. 참조타입::메소드이름 List<String> list = Arrays.asList("Apple", "Banana", "Orange"); Supplier<Integer> sizeSupplier = list::size;
    2. 참조변수::메소드이름
    3. 클래스이름::정적메소드이름
    4. 람다 표현식 대체 list.forEach(item -> System.out.println(item)); list.forEach(System.out::println); 둘 다 동일한 코드다.
    Share article

    Coding_study

    RSS·Powered by Inblog