Zaokrąglanie za pomocą DecimalFormat w Javie

Spójrzmy na następujące stwierdzenia w Javie.

<code>System.out.println(new DecimalFormat("0").format(2.4)); //returns 2

System.out.println(new DecimalFormat("0").format(2.5)); //returns 2  <---Concentrate here
System.out.println(Math.round(2.5));                    //returns 3

System.out.println(new DecimalFormat("0").format(2.6)); //returns 3
System.out.println(new DecimalFormat("0").format(3.5)); //returns 4
</code>

W powyższych stwierdzeniach wszystkie inne przypadki są oczywiste, z wyjątkiem poniższych.

<code>System.out.println(new DecimalFormat("0").format(2.5));
</code>

Powinien wrócić3 ale wraca2. W jaki sposób?

questionAnswers(2)

yourAnswerToTheQuestion