We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 16a3ace commit d686314Copy full SHA for d686314
java8Tutorials/src/main/java/java8/optional/OptionalDemo1.java
@@ -0,0 +1,22 @@
1
+package java8.optional;
2
+
3
+import java.util.Optional;
4
+import java.util.function.Consumer;
5
6
+public class OptionalDemo1
7
+{
8
+ public static void main(String[] args)
9
+ {
10
+ Optional<String> city=Optional.of("Pune");
11
+ System.out.println(city);
12
13
+ Optional<String> emptyGender = Optional.empty();
14
15
+ if (city.isPresent()) {
16
+ System.out.println("Value present.");
17
+ } else {
18
+ System.out.println("Value not present.");
19
+ }
20
+ city.ifPresent(a->System.out.println("value present"));
21
22
+}
0 commit comments