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 = new Address;
Optional<Address> addrs1 = Optional.ofNullable (address);
Employee e1 = new Employee (addrs1);
String eAddress = (addrs1.isPresent()) ? addrs1.get().getCity() : "City Not available";
System.out.println(eAddress);
What is the result?
Svetleto13
Highly Voted 4 years, 2 months ago6c84cb9
Most Recent 10 months agosteefaand
1 year, 5 months agoiSnover
1 year, 5 months agomaslac
4 years, 3 months agojduarte
4 years, 5 months agomaslac
4 years, 3 months ago