How to get 0-padded binary representation of an integer in java?

I think this is a suboptimal solution, but you could do

String.format("%16s", Integer.toBinaryString(1)).replace(' ', '0')

Leave a Comment