Given the code fragments:
class Employee {
Optional
address;Employee (Optional
address) {this.address = address;
}
public Optional
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
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?
Currently there are no comments in this discussion, be the first to comment!