hi in chapter 6...
in one question...
Given the following,
1. public class Example {
2. public static void main(
String [] args) {
3. double values[] = {-2.3, -1.0, 0.25, 4};
4. int cnt = 0;
5. for (int x=0; x < values.length; x++) {
6. if (Math.round(values[x] + .5) == Math.ceil(values[x])) {
7. ++cnt;
8. }
9. }
10. System.out.println("same results " + cnt + " time(s)");
11. }
12. }
what is the result?
A. same results 0 time(s)
B. same results 2 time(s)
C. same results 4 time(s)
D. Compilation fails.
E. An exception is thrown at runtime.
its anser is "B"
but don't understand why... i am not able to understand its explaination...
kindly clear the doubt...
thanx