0

How do i create a array String called computerMove and then make it choose a random element in the array?(In Java)

My array: String() computerMove = {"r", "p", "s"}; <---- (Make it choose one at random)

4th Aug 2022, 8:06 PM
Strawberry
Strawberry - avatar
1 Resposta
+ 3
Create an int using random up to 2, then it will pick from 0, 1 or 2, which should do what you want.
4th Aug 2022, 8:14 PM
Ausgrindtube
Ausgrindtube - avatar