Within java I wonder which of these is more efficient:
if(something)
{
if(something)
}
or
if((something) &&(something))
I was wondering what the merits are for both in terms of performance. Which solutions lend themselves better to different data objects.
Performance will be identical. The first statement will be evaluated and only if it is true will the second one be evaluated.
This is merely a question of readability. Unless there is something that needs to be done if the first statement is true, regardless of the second, I’d go with both in the same line as it is clearer that both statements need to be true for something to happen. You also don’t have to indent unnecessarily.