Binary format of an integer
<p>I have a method that prints out binary formar of numbers:</p>

<pre><code>private static void binary(int n){
   for(int i = 1; i &lt; Math.pow(2, n); i++)
      System.out.println(Integer.toBinaryString(i));
   }
} 
</code></pre>

<p>Output is like for n = 3:</p>

<pre><code>1
10
11
100
101
110
111
</code></pre>

<p>Is there a way to print out like this:</p>

<pre><code>001
010
011
100
101
110
111
</code></pre>
