I use this method:
def getRandomNumber(int num){
Random random = new Random()
return random.getRandomDigits(num)
}
when I call it I write println getRandomNumber(4)
but I have an error
No signature of method: java.util.Random.getRandomDigits() is applicable for argument types: (java.lang.Integer) values: [4]
Note: I use this method in another groovy class and it works properly without any error.
There is no such method as
java.util.Random.getRandomDigits.To get a random number use nextInt:
Also you should create the random object once when your application starts:
You should not create a new random object every time you want a new random number. Doing this destroys the randomness.