Example below is to show the code to generate random number. Try it :)
This example is at Learn Your Java From Here: Random-number generation
There are more example or Java learning in Learn Your Java From Here
Printable View
Example below is to show the code to generate random number. Try it :)
This example is at Learn Your Java From Here: Random-number generation
There are more example or Java learning in Learn Your Java From Here
This works alright, but also keep in mind that the Random class has more methods that make code such as this unnecessary.
The method you illustrated above is <Random>.nextInt(int n), where n = 10 in this case.