As described here:
We connect the object and its method (or property) call with a logical
AND operator (&&), so the method is only invoked if the object is
truthy (not null). This technique is commonly known as ‘andand’.
In Ruby, we’re able to do this:
name = @person && @person.name
This way we don’t have to explicitly check if @person is null.
Is there a similar technique in java?
Try
ternary operatorHowever it’s not very similar to&&technique, but works that way only.