Creating an object of Random class or using Math.random() in order to generate random numbers
<p>When you have imported java.util.Random, you can both generate random integers and random double two ways.</p>

<p>You could create an instance of the Random class</p>

<pre><code>Random randomGenerator = new Random();
</code></pre>

<p>and then use it to generate a random integer or double that is greater than or equal to 0 but less than 10</p>

<pre><code>int randomInteger = randomGenerator.nextInt(10);
double randomDouble = randomGenerator.nextDouble(10);
</code></pre>

<p>You can also use Math.random()</p>

<pre><code>int randomInteger = (int)(Math.random() * 10)
double randomDouble = Math.random() * 10
</code></pre>

<p>I think both methods gives the exact same result.
Is one of these two methods ever preferred rather than the other?</p>