When using the Integer.toBinaryString()
method to convert decimal to binary my program keeps returning the binary code without the leading 0's in the binary representation. How can I make sure that the zeros aren't lost? For example if the code is:
String binary = Integer.toBinaryString(84);
I get 1010100
instead of 01010100
How can I make sure that the leading zero doesn't disappear ?