목록BiPredicate (4)
SeouliteLab
BiPredicate의 negate() 메소드란? BiPredicate 인터페이스에는 논리 연산을 반대로 하는 negate() 메소드가 있습니다. 이 메소드는 BiPredicate의 조건을 부정합니다. 예제 1: 두 숫자가 모두 양수가 아닌지 확인하기 import java.util.function.BiPredicate; BiPredicate isNotPositive = (a, b) -> a a a > 100 || b > 100; BiPredicate tenOrLessOrHundredOrMore = isTenOrLess.or(isHundredOrMore); BiPredicate neitherTenOrLess..
BiPredicate의 and() 메소드란? BiPredicate 인터페이스에는 두 개의 BiPredicate를 하나로 결합하는 and() 메소드가 있습니다. 이 메소드는 두 BiPredicate가 모두 true를 반환할 때만 true를 반환합니다. 예제 1: 두 숫자가 모두 양수인지 확인하기 import java.util.function.BiPredicate; BiPredicate isPositive = (a, b) -> a > 0 && b > 0; BiPredicate bothPositive = isPositive.and(isPositive); boolean result1 = bothPositive.test(5, 7); boolean result2 = bothPositive.test(4, -6); S..
BiPredicate의 or() 메소드란? BiPredicate 인터페이스에는 두 개의 BiPredicate를 하나로 결합하는 or() 메소드가 있습니다. 이 메소드는 두 BiPredicate 중 하나라도 true를 반환하면 true를 반환합니다. 예제 1: 두 숫자가 양수인지 또는 짝수인지 확인하기 import java.util.function.BiPredicate; BiPredicate isPositive = (a, b) -> a > 0 && b > 0; BiPredicate isEven = (a, b) -> a % 2 == 0 && b % 2 == 0; BiPredicate positiveOrEven = isPositive.or(isEven); boolean result1 = positiveOrEv..
BiPredicate 인터페이스 소개 BiPredicate는 두 개의 인수를 받아들여 boolean 값을 반환하는 함수형 인터페이스입니다. 주로 두 개의 값 사이의 비교나 조건을 검사하는 데 사용됩니다. 예제 1: 두 정수의 합이 10보다 큰지 여부 import java.util.function.BiPredicate; BiPredicate sumGreaterThanTen = (a, b) -> a + b > 10; boolean result = sumGreaterThanTen.test(5, 6); System.out.println("Sum greater than 10? " + result); 이 예제에서는 BiPredicate를 사용하여 두 정수의 합이 10보다 큰지 여부를 검사합니다. 예제 2: 두 문자..