Skip to content

Instantly share code, notes, and snippets.

@david-mart
Last active April 5, 2018 03:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save david-mart/f90cddd47547bc44dd324435ccac4f33 to your computer and use it in GitHub Desktop.
Save david-mart/f90cddd47547bc44dd324435ccac4f33 to your computer and use it in GitHub Desktop.
import java.util.*;
public class MyClass {
static String[] firstNames = {"John", "Frank", "Nick", "Amanda", "Brittany", "Amy", "Deborah", "Stirling"};
static String[] lastNames = {"Thompson", "Smith", "Jones", "Keribarian", "Lu", "Banafsheh", "Spielberg", "Jordan", "Castle", "Simpson"};
static Random generator = new Random();
static int outputLength = 50;
static Set<String> outputNames = new HashSet<String>();
static String getRandomName () {
String firstName = firstNames[generator.nextInt(firstNames.length)];
String lastName = lastNames[generator.nextInt(lastNames.length)];
return firstName + ' ' + lastName;
}
static void getRandomNames () {
while (outputNames.size() < outputLength) {
String newName = getRandomName();
outputNames.add(newName);
}
}
public static void main(String args[]) {
getRandomNames();
System.out.print(outputNames);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment