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 3 years, 9 months ago6c84cb9
Most Recent 4 months, 3 weeks agosteefaand
11 months, 4 weeks agoiSnover
11 months, 4 weeks agomaslac
3 years, 10 months agojduarte
4 years agomaslac
3 years, 10 months ago