I\'m kinda waiting for a \'no\' answer on this question.
I was interested if you can save a variable at the same time when you checking it in an if-clause.
Three points that completely fail to answer the question:
null is evil. Don't write methods that return it. Your example problem would then disappear.
I think you might be missing out on encapsulation. Instead of foo.getBar() could the interface of foo be made such that you perform a "tell don't ask" operation?
Side-effects in expression tends to cause bad code. Prefer more, simpler lines to fewer, buggy lines. The usual exception if using ++ to increment an index when accessing a buffer, or similar iterator style algorithms.