Monday, August 8, 2016

java 8 tips

Here is an article about Java 8 top tips.

Java SE 8 Optional, a pragmatic approach

  1. Do not declare any instance variable of type Optional.
  2. Use null to indicate optional data within the private scope of a class.
  3. Use Optional for getters that access the optional field.
  4. Do not use Optional in setters or constructors.
  5. Use Optional as a return type for any other business logic methods that have an optional result.

No comments:

Post a Comment