Print double with exact length in java
<p>I could not find answer for my question on the net, so that's why I'm here.</p>

<p>I want to print a number with specified number of digits example in java:</p>

<pre><code>Length = 10

1.123456789      ==&gt; 1.123456789

123.123456789    ==&gt; 123.1234567

123456.123456789 ==&gt; 123456.1234
</code></pre>