I have written a simple Java program as shown here:
public class Test {
public static void main(String[] args) {
int i1 =2;
int i2=5;
double d = 3 + i1/i2 +2;
System.out.println(d);
}
}
Since variable d
is declared as double I am expecting the result of this program is 5.4
but I got the output as 5.0
Please help me in understanding this.
See Question&Answers more detail:os