<p>According to the answer key, the correct answer is B. However, I’m a little confused. I thought Math.random() would generate a number from 0 to 1, inclusive. This means that myList.size() becomes an obtainable value… which isn’t a valid index. Can someone tell me why my reasoning is wrong?</p>
<p>Math.random() generates a number from 0 to 1, inclusive on the left but exclusive on the right. In other words, it generates a nonnegative real number less than 1. So the answer is B.</p>