次の 3 つの機能のうち、より効率的なのはどれか。
public String getmConnectedDeviceName1() {
if(null != mServerDevice) {
return mServerDevice.getName();
}
else {
return null;
}
}
public String getmConnectedDeviceName2() {
return mServerDevice == null ? null : mServerDevice.getName();
}
public String getmConnectedDeviceName3() {
try{
return mServerDevice.getName();
}
catch(NullPointerException e) {
return null;
}
}
具体的に納得できる論理で回答してください。