Wednesday, 12 September 2018
Tuesday, 11 September 2018
Java 8: Using optional with nested objects
I am writing this blog for demonstrating the usage of Optional class in java8, with nested objects.
Consider below the class structure,
Now consider that, you want to extract an email from the Employee object, also you have to avoid null pointer exception. In a traditional way, you have to write a lot of NULL conditions.
Check below code with an Optional class which simplifies your code structure.
I will write a few more posts for using an Optional with collection classes.
Consider below the class structure,
Now consider that, you want to extract an email from the Employee object, also you have to avoid null pointer exception. In a traditional way, you have to write a lot of NULL conditions.
Check below code with an Optional class which simplifies your code structure.
I will write a few more posts for using an Optional with collection classes.
Subscribe to:
Posts (Atom)
-
Here I am trying to put some variations of printf statement in C language. These are not all, so lets share the other variations that you k...
-
1. The "contenteditable" attribute is used to... a) Update content dynamically from server. b) Allow the user to edi...
-
This is one of the useful class in java which is present in java.lang package. We can't instantiate this class manually means we can...