Ramesh-X
Ramesh-X
sudde gameeef wrote:i am making a game where i need to create object only onces randomly. <br/>
i can get random number by random object. but not sure how to put in if statment. <br/>
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Ramesh-X
sudde gameeef wrote:
Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
Ramesh Pramuditha Rathnayake wrote:This will give the same result as in yours. But this contains no unnecessary codes...
Jesper de Jong wrote:Almost the same. The original code didn't print anything if x was exactly equal to 0, 100 or 200. Also, the condition (x < 300) is unnecessary, because r.nextInt(300) will always produce a number less than 300.
Ramesh-X
Anayonkar Shivalkar wrote:If you need to create random number only once (and especially if you are not dealing with a series of random numbers), I would suggest to use 'random' method of 'Math' class.
It's quite easier than 'Random' class itself.
Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
Don't get me started about those stupid light bulbs. |