java - Convert integer to zero-padded binary string -


When int is converted to binary, then how is it output to 8 characters, at present it is only 1 Displays and less than 7 zeros

code

  int x = 1; String bin = integer. Baby string (x); Println (bin); For example 0000 0001   

I'm not sure if this is what you say but how < P>

  about something like string format ("% 8s", integer. Binary string (1)). ('', '0') instead of  

will generate 00000001


Comments