Possible Duplicate:
Java “?” Operator for checking null - What is it? (Not Ternary!)
I just read this article, which claims that:
Take the latest version of Java, which tries to make null-pointer checking easier by offering shorthand syntax for the endless pointer testing. Just adding a question mark to each method invocation automatically includes a test for null pointers, replacing a rat's nest of if-then statements, such as:
public String getPostcode(Person person) { String ans = null; if (person != null) { Name nm= person.getName(); if (nm!= null) { ans= nm.getPostcode(); } } return ans }With this:
public String getFirstName(Person person) { return person?.getName()?.getGivenName(); }
Aside from the fact that those pieces of code actually do different things1, is this the case, or it it an outright fabrication? I can't find any mention of that operator elsewhere...
1 unless the person in question frequently got lost, remedied only by making their given name their postcode