Last active
April 5, 2018 03:20
-
-
Save david-mart/f90cddd47547bc44dd324435ccac4f33 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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