+ 2

How do I generate random numbers in Java?

I need this function for my project. Revised the entire course, but did not find it. Tell me please

18th Nov 2020, 10:51 AM
Daniel
Daniel - avatar
4 Answers
+ 2
Daniel Use Random class in java It will easier your task .
18th Nov 2020, 11:09 AM
NavyaSri
NavyaSri - avatar
+ 1
Daniel And also u can use random()method of Math class. . Note: it is only for generating float or double numbers If you want to generate integer number then you must do type cast to int .
18th Nov 2020, 11:10 AM
NavyaSri
NavyaSri - avatar