Refactoring code in terms of cpu cycles JAVA
<p>Question:i just want to ask 2 question, if i write 2 below codes in java then which one is faster in terms of cpu cycles and why? Someone told me that 1st option is not correct in terms of cpu cycle because in that 2 conditions are checked i.e if and !</p>

<pre><code>boolean flag = true;
        1)
        if(!flag)
        {
              //error
        }
        else
        {
             //got the answer
        }

        2) 
        if(flag)
        {
              //got the answer
        }
        else
        {
             //error
        }
</code></pre>
