Why Using A Random In A Creator Code?
2 replies to this topic
Posted 18 July 2012 - 10:05 AM
Well I was wondering. the book has a lot of examples using constructors like
public ClassIWant(Random random, int something...)
In which I need an instance to a Random Object. If I need a Random object to generate data. Wouldn't it be easier just to get it instantiated directly in the Creator without having to get an instance of this Random guy?
I mean, it's random isn't? I think it adds some unwanted complexity to the code doesn't?
Posted 18 July 2012 - 05:14 PM
It's considered best practice to use one instance of the Random class to generate random numbers. You can find why here. I quoted the important part of this page.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users