I have written the following program in Java to convert long to byte.
    public class LongtoByte 
    {
            public static void main(String[] args)
            {
                long a=222;
                byte b=(byte)(a & 0xff);
                System.out.println("the value of b is" +b);
            }
    }
The problem is I get the result -34 for the variable b.
Please tell me how to get the correct value. I want the value in bytes only.
 
     
     
     
     
     
    