This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Marco Ehrentreich wrote:why is Math.random() helpless in this case??
There are probably different ways how you get to a specific file but in any case you will need something to produce random values. Why not use Math.random() for this?
I think Meet has problems transforming the double to an int.
It's quite easy though. To return a number between A (inclusive) and B (exclusive), the calculation is as follows: In your case this would be Math.random() * 41. Note the 41 - Math.random() will never return 1.0, so Math.random() * 41 will always be smaller than 41. Cast it to int, and the maximum value returned is 40.
But you'll probably find java.util.Random and its nextInt() method a lot easier.