0

I was wondering if anyone could give me any insight as to how I would go about creating an array of random Strings?

I want to use this array to test the time it takes different sorting methods to execute.

Bell
  • 69
  • 4
  • 12

2 Answers2

0

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/

bladnman
  • 2,591
  • 1
  • 25
  • 20
0

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;
}
James M
  • 33
  • 1
  • 4