Back
Close

Java Guild Meeting 5/2018

Gi11i4m
3,173 views

Optionals

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

Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants