Long to Byte Conversion
<p>I have written the following program in Java to convert long to byte.</p>

<pre><code>    public class LongtoByte 
    {
            public static void main(String[] args)
            {
                long a=222;
                byte b=(byte)(a &amp; 0xff);
                System.out.println("the value of b is" +b);

            }
    }
</code></pre>

<p>The problem is I get the result -34 for the variable b. </p>

<p>Please tell me how to get the correct value. I want the value in bytes only.</p>
