Java Guild Meeting 5/2018


Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content


Optionals are a language concept that have been introduced in Java 8.

A story of why optionals have been introduced can be found here

Optionals are represented by the Optional class in the java.util package and it is used to represent if a value is present or absent. The main advantage of this new construct is that it can avoid too many null checks and it avoids any runtime NullPointerExceptions. Optionals also support us in developing clean APIs, as they express intent that a value might be absent.

In today's exercises, the focus will be on:

  • Syntax of Optionals
  • What to do when an API returns an Optional
  • Optionals and Streams

Documentation about Optionals can be found here

Open Source Your Knowledge: become a Contributor and help others learn. Create New Content