title: How to skip evaluating remaining part of arithmetic expression after 0 * ... in Java
body: <p>In logic expressions remaining part would be skipped if it is unnecessary</p>
  
  <pre><code>boolean b = false &amp;&amp; checkSomething( something)
  //checkSomething() doesn't get called
  </code></pre>
  
  <p>What is a good way to achieve the same with arithmetic expressions ?</p>
  
  <pre><code>int i = 0 * calculateSomethig ( something ) 
  </code></pre>
  
  <p>It is possible to add ifs before * . But is there a more elegant way to solve this problem? Without of adding much stuff into expression, so that expression itself would look as close to original as possible</p>
  
  <p>Why i do not want to use ifs?
  from </p>
  
  <pre><code>return calculateA() * calculateB()
  </code></pre>
  
  <p>it'll become bulky and unclear</p>
  
  <pre><code>int result
  int a = calculateA();
  if (a!=0) {
      result = a*calculateB()
  }else{
      result = 0
  }
  return result
  </code></pre>
  
  <ul>
  <li>8 lines of code instead of 1, </li>
  <li>those expressions might be more complex than a*b</li>
  <li>those expressions represent business logic so i want to    keep them
  clear and easily readable</li>
  <li>there might be whole bunch of them</li>
  </ul>
  
  <p>Why do i bother with this at all?
  Because calculation methods might be expensive</p>
  
  <ul>
  <li>uses values form other places, where searches and sorts are happening</li>
  <li>lots of those expressions can be executed at once ( after user event and user should see result "instantly"</li>
  <li>P( *0 in expression ) >0.5</li>
  </ul>