True. Even then, this is probably not the code he really wants.
Instead of using casts on a Random method returning doubles, he could
use the java.lang.util.Random.nextInt() method to get an integer in
the range he specifies.
Then instead of "(int( (Math.random()*9)+1" he could have, after a
decla
The value of this expression will always be zero:
(int) Math.random()
Casting to an integer removes the fractional portion. Casting has a
higher operator precedence than multiplication or addition, so happens
first in your full expression. Parentheses could be used to alter when
the cast happens,
2 matches
Mail list logo