`Optional` represents a value that may be present or absent and forces the caller to handle the empty case. A common misuse is using it as a field in entities/DTOs everywhere; it’s mainly intended for return values, not for serialization or persistence fields.
Optional<User> user = repo.findById(id);
String name = user.map(User::getName).orElse("unknown");
Advanced answer
Deep dive
Expanding on the short answer — what usually matters in practice:
Context (tags): optional, null-safety, api
JVM: memory (heap/stack), GC, and what drives latency.
Contracts: equals/hashCode/toString, mutability and consequences.