Convert integer to zero-padded binary string
binary, java
Solution
I am not sure if that is what you mean but how about something like
String.format("%8s", Integer.toBinaryString(1)).replace(' ', '0')
will generate `00000001`
Problem
when converting int to binary, how to output it to 8 character, currently it only display 1 and short of the 7 zeros code ``` int x = 1; String bin = Integer.toBinaryString(x); System.Out.Println(bin); ``` example output to 0000 0001