The division of two integers in Java is also an integer.
E.g.
int a=5;
int b=10;
System.out.println(a/b);
It will output 0.
One could use double instead.
E.g.
double a=5;
double b=10;
System.out.println(a/b);
It will output 0.5.
More here: http://stackoverflow.com/questions/8110019/java-divison-with-two-integer-operands-not-working
No comments:
Post a Comment