What is the purpose and behavior of `Optional` in Java 8+?

Java Associate Hard

Java Associate — Hard

What is the purpose and behavior of `Optional` in Java 8+?

Key points

  • `Optional` is not a generic type for making any type nullable
  • It is not a thread-safe reference type for concurrent programming
  • `Optional` is not a lazy-loading container for deferring object creation

Ready to go further?

Related questions