fork(369) download
  1.  
  2. class Main
  3. {
  4. public static void main (String[] args) throws java.lang.Exception
  5. {
  6. byte b1 = (byte) 129;
  7. String s1 = String.format("%8s", Integer.toBinaryString(b1 & 0xFF)).replace(' ', '0');
  8. System.out.println(s1); // 10000001
  9.  
  10. byte b2 = (byte) 2;
  11. String s2 = String.format("%8s", Integer.toBinaryString(b2 & 0xFF)).replace(' ', '0');
  12. System.out.println(s2); // 00000010
  13. }
  14. }
Success #stdin #stdout 0.03s 245632KB
stdin
Standard input is empty
stdout
10000001
00000010