0

Optional is documented as:

An immutable object that may contain a non-null reference to another object. Each instance of this type either contains a non-null reference, or contains nothing (in which case we say that the reference is "absent"); it is never said to "contain null".

Can you help with an example of the usefulness of the Optional class? when might I use it as opposed to something else?

dimo414
  • 44,897
  • 17
  • 143
  • 228
j2emanue
  • 56,631
  • 57
  • 264
  • 415
  • 1
    Since you surely did some research before you asked, you also have found [this page](https://code.google.com/p/guava-libraries/wiki/UsingAndAvoidingNullExplained), right? – Tom May 06 '15 at 00:16
  • Use it anywhere you would consider using `null` to represent absence. Simple as that. – dimo414 May 06 '15 at 00:20

0 Answers0