fork(1) 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) throws java.lang.Exception
  11. { // https://ru.stackoverflow.com/questions/717403/%D0%BA%D0%B0%D0%BA-%D0%B7%D0%B0%D0%BD%D1%83%D0%BB%D0%B8%D1%82%D1%8C-%D0%BF%D0%B5%D1%80%D0%B2%D1%8B%D0%B5-4-%D0%B1%D0%B8%D1%82%D0%B0-%D0%B2-%D0%B1%D0%B0%D0%B9%D1%82%D0%B5-%D0%BD%D0%B0-java
  12. byte b = 63;
  13. System.out.println(bin(b));
  14. b >>>= 4;
  15. System.out.println(bin(b));
  16. byte b2 = 63;
  17. System.out.println(bin(b2));
  18. b2 = (byte)((b2 & 0xf0) >> 4);
  19. System.out.println(bin(b2));
  20. }
  21. static String bin(byte b) {
  22. return Integer.toBinaryString((b & 0xFF) + 0x100).substring(1);
  23. }
  24. }
Success #stdin #stdout 0.05s 4386816KB
stdin
Standard input is empty
stdout
00111111
00000011
00111111
00000011