String name = Optional.of("baeldung").orElseGet(() -> getRandomName()); String name = Optional.of("baeldung").orElse(getRandomName());