simple question - change bits in java
<p>I have a simple question - I need to write a function for my program to change the 3rd bit of a given byte.</p>

<p>I wrote those lines :</p>

<pre><code>public byte turnOn(Byte value)
{
    int flag = 8;
    value = (byte) (value | flag);
    return value;
}
</code></pre>

<p>I'm not sure if it's the right way to do that, because I saw also this way (with which I am unfamiliar)</p>

<pre><code>value = (byte) (value | (1 &lt;&lt; 2) );
</code></pre>

<p>which way is better, and what does 1 &lt;&lt; 2 means (2 means the third bit, but what is the 1 )</p>

<p>Thanks! </p>
