title: java byte to binary conversion
body: <p>Based on my statements below I have few questions. Please explain.</p>
  
  <p>Q1. Why the output is same for items 2 and 4. I guess it is because byte 128 is equal to byte -128</p>
  
  <p>Q2. Why the output for items 2 and 4 are padded with 1s on the left where the output is supposed to be just this 10000000. I guess.</p>
  
  <p>Q3. What is the difference between outputs 2 and 3 even though the last out 8 bits looks same.</p>
  
  <pre><code>1. System.out.println("1==&gt;"+Integer.toBinaryString((byte)127));
  2. System.out.println("2==&gt;"+Integer.toBinaryString((byte)128));
  3. System.out.println("3==&gt;"+Integer.toBinaryString(128));
  4. System.out.println("4==&gt;"+Integer.toBinaryString((byte)-128));
  </code></pre>
  
  <h2>output :</h2>
  
  <pre><code>1==&gt;1111111
  
  2==&gt;11111111111111111111111110000000
  
  3==&gt;10000000
  
  4==&gt;11111111111111111111111110000000
  </code></pre>