[Java] Method Reference (메서드 레퍼런스의 4가지 케이스)
✔ ClassName::staticMethodName 클래스의 static method를 지정할 때 (Method명 만) integer → String String.valueOf(); String → integer Integer.parseInt(); Function str2int = Integer::parseInt; int five = str2int.apply("5"); ✔ ObjectName::instanceMethodName 이미 선언되어있는 객체의 instance method를 지정할 때 String str = "hello"; Predicate equalsToHello = str::equals; boolean helloEquealsWorld = equalsToHello.test("world"); ✔..
Java/Stream
2022. 10. 5. 10:52