int i = 5;
if (Math.sqrt(i + 1) < 4.5) { /* ... */ }
So, the idea is to work outward with types:
- What's the type of expression 'i'? int
- What's the type of expression '1'? int
- What's the type of expression 'i + 1'? int (then converted to double)
- What's the type of expression 'Math.sqrt(i + 1)'? double
- What's the type of expression '4.5'? double
- What's the type of expression 'Math.sqrt(i + 1) < 4.5'? boolean (required for if)
No comments:
Post a Comment