Generating random words in Java?

前端 未结 6 1738
抹茶落季
抹茶落季 2021-02-14 09:47

I wrote up a program that can sort words and determine any anagrams. I want to generate an array of random strings so that I can test my method\'s runtime.

publi         


        
6条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-14 10:23

    If you want random words without using a dictionary...

    1. Make a list of all the letters you want possible in your words
    2. Generate a random index to pick out a letter from the list
    3. Repeat until you have your desired word length

    Repeat these steps for the number of words you want to generate.

提交回复
热议问题