This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma 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.