mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
14 lines
301 B
Java
14 lines
301 B
Java
// "Use 'orElseGet' method with functional argument" "true-preview"
|
|
|
|
import java.util.Optional;
|
|
|
|
class Test {
|
|
String createDefaultString(int x) {
|
|
return "foo"+x;
|
|
}
|
|
|
|
public void test(Optional<String> opt) {
|
|
int x = 5;
|
|
String result = opt.orElseGet(() -> createDefaultString(x));
|
|
}
|
|
} |