How to user the Random class with strings? (import java.util.Random) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to user the Random class with strings? (import java.util.Random)

Hey, I looked in the web und searched, but I don't found , how I can use the random class with strings. I only found it with for example 1 <60 , bit I need to programm random words... Can I also make System.out.println("Hello" || "Bye" || "Chao" || "...")? Or isnt it possible? Thanks for help. Getman answers are better then english , but both is ok.

12th Mar 2017, 6:41 AM
nwytg
1 Answer
0
You can create an array with the words in it and get the item at a random index
15th Mar 2017, 12:16 AM
thomas smith
thomas smith - avatar