fork(2) 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 = 0b0110_0010;
  13. System.out.println(bin(b));
  14. b &= 0b0000_1111;
  15. System.out.println(bin(b));
  16. }
  17. static String bin(byte b) {
  18. return Integer.toBinaryString((b & 0xFF) + 0x100).substring(1);
  19. }
  20. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
01100010
00000010