title: Checking the "boolean" result of an "int" type
body: <p>I'm learning Java, coming from C and I found an interesting difference between languages with the <code>boolean</code> type. In C there is no <code>bool</code>/<code>ean</code> so we need to use numeric types to represent boolean logic (<code>0 == false</code>).</p>
  
  <p>I guess in Java that doesn't work:</p>
  
  <pre><code>int i = 1;
  if (i)
      System.out.println("i is true");
  </code></pre>
  
  <p>Nor does changing the conditional via a typecast:</p>
  
  <pre><code>if ((boolean)i)
  </code></pre>
  
  <p>So besides doing something like:</p>
  
  <pre><code>if ( i != 0 )
  </code></pre>
  
  <p>Is there any other way to do a C-ish logic check on an <code>int</code> type? Just wondering if there were any Java tricks that allow boolean logic on non-boolean types like this.</p>
  
  <hr>
  
  <p><strong>EDIT:</strong> 
  <br>The example above was very simplistic and yields itself to a narrow scope of thinking. When I asked the question originally I was thinking about non-boolean returns from function calls as well. For example the Linux <code>fork()</code> call. It doesn't return an <code>int</code> per se, but I could use the numeric return value for a conditional nicely as in:</p>
  
  <pre><code>if( fork() ) {
      // do child code
  </code></pre>
  
  <p>This allows me to process the code in the conditional for the child, while not doing so for the parent (or in case of negative return result for an error). </p>
  
  <p>So I don't know enough Java to give a good "Java" example at the moment, but that was my original intent.</p>