Decimal format in Java?
<p>can someone explain to me why the output for this: </p>

<pre><code>    double y = 15/7;
    DecimalFormat first = new DecimalFormat("#.###");
    System.out.println(y); 
    String format_string = first.format(y);
    System.out.println(format_string);
</code></pre>

<p>Is this:</p>

<pre><code>   2.0
   2
</code></pre>

<p>(Which is wrong)</p>

<p>However, when I change 15/7 to</p>

<pre><code> 15.0/7.0
</code></pre>

<p>It gives me the correct answer</p>

<pre><code> 2.142857142857143
 2.143
</code></pre>

<p>Explanation please?</p>

<p>Thank you!</p>
