So lets consider this following statement that executes more than a million times inside a loop.
boolean validity = condition1 || condition2;
It is safe to assume that both condition1 and condition2 have very complex calculation inside them. So since there is an OR operator here, I assume it would be wise to separately check for condition1 first and then if necessary, condition2 afterwards like,
boolean validity = condition1;
if( !validity )
validity = condition2;
Should I manually perform optimizations like this or does the java compiler automatically takes care of these things?