Regardless of performance, I would prefer the if-else form. Suppose mServerDevice is not null, but something goes badly wrong during the getName() call and it throws a NullPointerException. The exception-based version will silently return null, without logging the error.