Код: Выделить всё
Object value = getValue();
Objects.requireNonNullelse(value, () -> throw new MyRuntimeException("Error message"));
Код: Выделить всё
Object value = getValue();
Objects.requireNonNullelse(value, () -> {throw new MyRuntimeException("Error message");});
Подробнее здесь: https://stackoverflow.com/questions/798 ... -exception
Мобильная версия