/
konick_gs
/
netology-lambda
Обзор
Документация
Войти
/
konick_gs
/
netology-lambda
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
lambda/task1/Calculator.java
26 строк
777 B
gilsar
Правка
04 июл 2026, 22:17
04 июл 2026, 22:17
a87f39b
Код
Авторство
О чём код?
package lambda.task1; import java.util.function.*; public class Calculator { public static Supplier<Calculator> instance = Calculator::new; public BinaryOperator<Integer> plus = (x, y) -> x + y; public BinaryOperator<Integer> minus = (x, y) -> x - y; public BinaryOperator<Integer> multiply = (x, y) -> x * y; public BinaryOperator<Integer> divide = (x, y) -> { try { return x / y; } catch (ArithmeticException e) { System.err.println(e); return 0; } }; public UnaryOperator<Integer> pow = x -> x * x; public UnaryOperator<Integer> abs = x -> x > 0 ? x : x * -1; public Predicate<Integer> isPositive = x -> x > 0; public Consumer<Integer> println = System.out::println; }