Given the code fragments:
class Employee {
Optional<Address> address;
Employee (Optional<Address> address) {
this.address = address;
}
public Optional<Address> getAddress() { return address; }
}
class Address {
String city = "New York";
public String getCity { return city: }
public String toString() {
return city;
}
}
and
Address address = null;
Optional<Address> addrs1 = Optional.ofNullable (address);
Employee e1 = new Employee (addrs1);
String eAddress = (addrs1.isPresent()) ? addrs1.get().getCity() : "City Not available";
What is the result?
adnano1234
Highly Voted 4 years, 6 months agoasdfjhfgjuaDCV
Most Recent 4 months, 4 weeks agosteefaand
5 months, 4 weeks agor1muka5
1 year, 5 months agoDestroyer
4 years, 7 months ago