fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main(String[] args) {
  11.  
  12. byte b = 122;
  13. for (byte i = 0; i < 10; i++) {
  14. b = (byte) (b + 1);
  15. String str = "00" + Integer.toBinaryString(b);
  16. str = str.substring(str.length() - 8);
  17. System.out.printf("%s <> %4d%n", str, b);
  18. }
  19.  
  20. }
  21. }
Success #stdin #stdout 0.05s 2184192KB
stdin
Standard input is empty
stdout
01111011  <>   123
01111100  <>   124
01111101  <>   125
01111110  <>   126
01111111  <>   127
10000000  <>  -128
10000001  <>  -127
10000010  <>  -126
10000011  <>  -125
10000100  <>  -124