how to add value to an optional java code example Example: instantiate optinal java 8 Person p = new Person(); Optional<Person> op = Optional.of(p);