How to generate random numbers using Java in a given number list

Suppose I have a number / vector number, such as 1,3,7,9, and then I need to guess the number in this list at random Using random in Java is almost impossible Anyone can help me point out the way to do this I have to change the list of numbers used to generate random numbers I'm trying to implement a strategy to automatically play the battleship game as a mission Please help me do this?

Solution

Put numbers in ArrayList and use collections shuffle(arrayList);

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>