+ 1
Random in Java
How can i randomize string variables in java and would want to use random with JOptionPane. For example I want the user to give their name using JOptionPane then their name will be allocated to a color and the colors must be randomly selected.
2 ответов
+ 2
Here are three ways to create a random number:
https://www.google.de/amp/s/www.geeksforgeeks.org/generating-random-numbers-in-java/amp/
If your color is in a list or array, you could create a random number between 0 and length of list/array for the index.