what is the difference between & and &&?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/4014535/vs-and-vs">&amp; vs &amp;&amp; and | vs ||</a>  </p>
</blockquote>



<p>what is the difference between <code>&amp;</code> and <code>&amp;&amp;</code>?</p>

<p>I am getting same output for both <code>&amp;</code> and <code>&amp;&amp;</code>.</p>

<h2>Ex:</h2>

<ol>
<li><p><code>&amp;&amp;</code>:</p>

<pre><code>if (true &amp;&amp; true){
    System.out.println("------if------");
} else {
    System.out.println("------else------");
}
</code></pre></li>
<li><p><code>&amp;</code>:</p>

<pre><code>if (true &amp; true){
    System.out.println("------if------");
} else {
    System.out.println("------else------");
}
</code></pre></li>
</ol>

<h2>Output:</h2>

<ol>
<li><code>------if------</code></li>
<li><code>------if------</code></li>
</ol>

<p>Can we use <code>&amp;</code> and <code>&amp;&amp;</code> operators in our code interchangeably?</p>
