If you divide the integer ( int ) by another integer ( int ), the result will be an integer ( int ). - More: 15.17 Multiplicative Operators
You need to mark one or both as double
or
Note that java.lang.Integer is an immutable wrapper type, not int ! - In fact, you cannot calculate using java.lang.Integer , but with Java 1.5, the compiler will convert int to Integer and vice versa automatically (automatic boxing and auto unpacking). But in general, it is better to understand the difference and use Integer only if you need real objects (and not numbers to calculate).
Ralph source share