当前位置: 动力学知识库 > 问答 > 编程问答 >

Creating an array of Random Strings [Java]

问题描述:

This question already has an answer here:

  • How to generate a random alpha-numeric string?

    38 answers

网友答案:

Bell, I have a very simple class that may help with "semi-random" data. It's extremely easy to use and will give you different types of strings for your data.

Maybe it will help. Other answers around here will give you true fuzz data if that's what you're looking for. Good luck!

PhraseGenerator

http://metal-sole.com/2012/10/12/random-phrases-computers-is-funny/

网友答案:

When you say random Strings do you mean random numbers stored as Strings?

public static String[] generateArray(int size){

    String[] arr= new String[size];
    int[] val = new int[size];

    for (int i=0; i<arr.length; i++) {
        val[i] = (int)(100 * Math.random());
        arr[i] = String.valueOf(val[i]);
    }

    return arr;
}
分享给朋友:
您可能感兴趣的文章:
随机阅读: