I am answering this very late, but this is what really useful for new reader. This is a very simple and efficient way to get random VALID names. To do so, add maven repository in POM.xml

<dependency>
    <groupId>com.github.javafaker</groupId>
    <artifactId>javafaker</artifactId>
    <version>0.12</version>
</dependency>

And then use the Faker class as below in your Java code

Faker faker = new Faker();

String name = faker.name().fullName();
String firstName = faker.name().firstName();
String lastName = faker.name().lastName();

String streetAddress = faker.address().streetAddress();

Try printing the result using standard System.out.println();

For more reference Faker Lib

Answer from Gaurav Lad on Stack Overflow
๐ŸŒ
GitHub
github.com โ€บ ajbrown โ€บ name-machine
GitHub - ajbrown/name-machine: Generate realistic random American male and female names. ยท GitHub
Name machine is a Java utility for generating random names with realistic probabilities of occurrence.
Starred by 56 users
Forked by 9 users
Languages ย  Java 93.7% | Groovy 6.3%
Discussions

natural language processing - Random name generator in Java - Code Review Stack Exchange
I wrote working random name generator in Java. More on codereview.stackexchange.com
๐ŸŒ codereview.stackexchange.com
June 13, 2017
[Java] I wrote a random name generator
Overall, looks pretty good! A few things I noticed: Make sure you are very intentional with your pluralization. For example, in the line Name names = new Name(), you have inconsistent pluralization. Which is it โ€” one name, or multiple names? In Name, you have some places where you have hardcoded the length of some of your various arrays. This isn't good, because this means that if you want to update the contents of one of the arrays, you will have to change multiple places in your code, where you should only need to change one place in your code for such a change. Similarly, in UserInterface, you have one area that prints out a numbered list of all the actions that the user can choose from, but the logic that goes along with each of those actions is elsewhere in the file. It would be good to use a data structure such that if you needed to add an action, remove an action, or rearrange the actions, you could do so by only making one edit to the code, not multiple edits. More on reddit.com
๐ŸŒ r/learnprogramming
18
13
July 1, 2025
java - How To Randomly Generate From A Given List? - Stack Overflow
The problem I'm running into is to randomly generate names from a specific list. I want my program to be able to only pick from these names: Bob, Jill, Tom, and Brandon. I tried studying arrays but I More on stackoverflow.com
๐ŸŒ stackoverflow.com
Generate Heroku-like random names to use in your Java applications (github.com/atrox/haikunatorjava)

Any thoughts on why you went with a Map<String,Object> for configuration instead of a builder, a configuration object, or a set of constructors? I suspect you are using a Map in order to mimic Ruby's option hash, but this isn't idomatic Java and seems a bit error-prone. If you must use the Map for configuration, I'd at least provide some constants. Or an enumeration and change the configuration to Map<MyEnum,Object> to constrain the types. But I'd see about losing the Map in favor of something else.

Also, it would be nice to provide a way to actually change the words being used. Hard coding them into the app doesn't provide as much value. As a user, I should be able to configure the word lists.

Don't let this discourage you, keep working.

Edit: If you are only using one method (StringUtils.join) from Apache Commons, I'd consider dropping the dependency and writing my own join method. But that's fairly subjective and I don't like having many dependencies if I can avoid them.

More on reddit.com
๐ŸŒ r/java
6
20
April 28, 2015
๐ŸŒ
GitHub
github.com โ€บ igr โ€บ nomen-est-omen
GitHub - igr/nomen-est-omen: Random names generator, with a style. ยท GitHub
"Your name is your destiny", so be sure you pick a good name. This Java library helps with generating some super-awesome random names that you can use for some unique IDs or passwords :)
Starred by 47 users
Forked by 4 users
Languages ย  Java
Top answer
1 of 1
3

Consider Regex

Your WordChecker class has numerous helper methods that all bubble up to just pattern matching. This is exactly why Regex exists, Java has Pattern and Matcher classes in java.util.regex that can help you do this fairly succinctly. For example, to check for only vowels or only consonants you can have this:

public class WordChecker {
    private static final Pattern VOWEL_PATTERN = Pattern.compile("^[aeiouy]+$");
    private static final Pattern CONSONANT_PATTERN = Pattern.compile("^[bcdfghjklmnpqrstvwxz]+$");

    private static boolean onlyVowels(String input) {
        return VOWEL_PATTERN.matcher(input).matches();
    }

    private static boolean onlyConsonants(String input) {
        return CONSONANT_PATTERN.matcher(input).matches();
    }
}

Do note, however, that I make these methods static, so call them with WordChecker.onlyVowels("..."); As it stands all the content consists of helper functions independent of any particular implementation so being static fits well.

For further reference look at the documentation here.

Use meaningful names; avoid deceptive names.

Naming things can be surprisingly difficult especially when striving to keep it short and indicate full meaning, yet only returning 0 or 1 seems completely unexpected from a method that is meant to return the similarity between two things (similarity implies a multitude of outputs on a range, the way you apply it here essentially turn it into a boolean).

Leverage the API

One of the premier merits of using any language in particular is the available libraries. Unless this was done as an exercise the majority of the Dictionary class can be eliminated by using a HashMap.

๐ŸŒ
GitHub
github.com โ€บ kohsuke โ€บ wordnet-random-name
GitHub - kohsuke/wordnet-random-name: Human friendly random name generator for tests
This little library generates human friendly random identifiers. For example, given the following code, RandomNameGenerator rnd = new RandomNameGenerator(0); for (int i=0; i<10; i++) System.out.println(rnd.next()); ... constructive_carrot ...
Starred by 137 users
Forked by 34 users
Languages ย  Java 100.0% | Java 100.0%
๐ŸŒ
GitHub
github.com โ€บ mperalc โ€บ name-generator
GitHub - mperalc/name-generator: Java library to generate random name(s) from different languages/cultures
Java library to generate random name(s) from different languages/cultures - mperalc/name-generator
Author ย  mperalc
Find elsewhere
๐ŸŒ
GitHub
github.com โ€บ folkengine โ€บ java-random-name-generator
GitHub - folkengine/java-random-name-generator: Generates random names from syllables
March 21, 2016 - Generates random names from syllables. Contribute to folkengine/java-random-name-generator development by creating an account on GitHub.
Starred by 5 users
Forked by 2 users
Languages ย  Java 100.0% | Java 100.0%
๐ŸŒ
Open Hub
openhub.net โ€บ p โ€บ janag
The JaNaG - Java Name Generator Open Source Project on Open Hub
JaNaG (Java Name Generator) is a random name generator for role-games, authors, and the like. It is based on a name fragment database that creates relatively reasonably sounding names from different cultures/influences (e.g. elves, orcs, pseudo-old-German, etc.).
๐ŸŒ
Medium
reedanna.medium.com โ€บ creating-a-simple-random-generator-in-java-43d2ac47543c
Creating a Simple Random Generator in Java | by Anna Reed | Medium
January 8, 2021 - Probably at the random generation utility itself. To begin with, I imported the java.util.Random class and created a new Random instance that I named rand.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnprogramming โ€บ [java] i wrote a random name generator
r/learnprogramming on Reddit: [Java] I wrote a random name generator
July 1, 2025 -

Hey there! I recently started learning java a couple weeks ago as my first language, mostly out of interest in developing some mods for minecraft. After getting comfortable with java, I intend to learn C# and pursue other interests involving game development.

At any rate, I've always loved coming up with unique names. So I thought why not challenge myself with writing a random name generator that doesn't just spit out nonsense. I feel comfortable calling the project complete for now although I could add more and more functionality, I do want to get on with continuing to learn.

I would appreciate feedback on my coding, even if it's a fairly simple project. Am I doing things moderately well? Does anything stand out as potentially problematic in the future if I carry on the way I have here? Am I writing too much useless or needless code? I am trying to ensure I don't solidify any bad habits or practices while I'm still learning fresh.

The project is at https://github.com/Vember/RandomNameGenerator

Greatly appreciate any feedback!

Top answer
1 of 2
3
Overall, looks pretty good! A few things I noticed: Make sure you are very intentional with your pluralization. For example, in the line Name names = new Name(), you have inconsistent pluralization. Which is it โ€” one name, or multiple names? In Name, you have some places where you have hardcoded the length of some of your various arrays. This isn't good, because this means that if you want to update the contents of one of the arrays, you will have to change multiple places in your code, where you should only need to change one place in your code for such a change. Similarly, in UserInterface, you have one area that prints out a numbered list of all the actions that the user can choose from, but the logic that goes along with each of those actions is elsewhere in the file. It would be good to use a data structure such that if you needed to add an action, remove an action, or rearrange the actions, you could do so by only making one edit to the code, not multiple edits.
2 of 2
2
Actually quite a fun project, and it is obvious that you've had fun playing around with making the code - that's a good thing! This is only comments for the UserInterface, and mostly ideas for further improvements. I like the processCommand method, and you should take it further still, and make separate methods for each command - like generateRandom, generateWithLength, generateWithLetter, or what you prefer to name them, and then only let processCommand decide which of them to call. Also, not sure why you use Integer.valueOf to test the value of ints, usually writing if (command == 1) should be sufficient. You might want to use a switch-case for the commands instead of a chain of if-statements. It might make the code look better, something like: switch(command) { case 1 -> generateRandom(); case 2 -> generateWithLength(); case 3 -> generateWithLetter(); and so on. But it is a matter of taste. You could benefit from making a single method for reading a valid number from the input - something like: getValidInput(int[] numbers) that would only return one of the numbers in the array, or zero if something else was entered by the user. That would isolate your use of scanner to that method alone, and make the rest of the code easier to write without having to handle exceptions or different invalid inputs. It is always a good idea to have a lot of small methods that only do one thing - my own personal rule is that if I have more than two levels of if-statements or loops, I need to make a method to combine them. The less indentation the better :)
๐ŸŒ
GitHub
github.com โ€บ arakelian โ€บ faker
GitHub - arakelian/faker: A Java library for generating fake data such as names, addresses, and phone numbers.
A Java library for generating fake data such as names, addresses, and phone numbers. - arakelian/faker
Starred by 25 users
Forked by 2 users
Languages ย  Java 100.0% | Java 100.0%
๐ŸŒ
GitHub
github.com โ€บ xdrop โ€บ jRand
GitHub - xdrop/jRand: A Java library to generate random data for all sorts of things. Java random data faker
JRand is heavily inspired by ChanceJS and tries to bring together a lot of that functionality to Java. In JRand there are Generator's which are reusable components to generate all sorts of things. You can get access to any generator you wish via the JRand facade class. The library is still under development with weekly releases of new generators. Builder style random data generators with a lot of options
Starred by 27 users
Forked by 14 users
Languages ย  Java 73.0% | Groovy 20.1% | Kotlin 6.7% | Shell 0.2% | Java 73.0% | Groovy 20.1% | Kotlin 6.7% | Shell 0.2%
๐ŸŒ
SourceForge
sourceforge.net โ€บ projects โ€บ janag.berlios
JaNaG - Java Name Generator download | SourceForge.net
June 9, 2014 - Random name generator library with rule files. Fast, lightweight and easy.
๐ŸŒ
CopyProgramming
copyprogramming.com โ€บ howto โ€บ random-name-generator-in-java
Random Name Generator in Java : Best Practices, Code Examples, and Latest Java Features
December 31, 2025 - A random name generator in Java is a Java class or service that programmatically creates random human names, usernames, or identifiers using libraries like java.util.Random, SecureRandom, and collections APIs.
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ java string โ€บ java โ€“ generate random string
Java - Generate Random String | Baeldung
May 11, 2024 - @Test public void givenUsingAp... bounded and unbounded strings with either plain Java, a Java 8 variant, or the Apache Commons Library....
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ testing โ€บ a guide to javafaker
A Guide to JavaFaker | Baeldung
May 11, 2024 - compile group: 'com.github.javafaker', name: 'javafaker', version: '0.15' The FakeValueService class provides methods for generating random sequences as well as resolving .yml files associated with the locale.
๐ŸŒ
Medium
medium.com โ€บ @reachansari โ€บ generate-random-data-using-java-faker-d2b049f4eb44
Generate Random Data using Java Faker | by Thameem Ansari | Medium
December 29, 2021 - Faker faker = new Faker(new Locale("en-US")); faker.name().fullName(); faker.name().firstName(); faker.name().lastName(); In this article, we explored how we can use this library to generate some random data across various domains and locale. This library is useful to do development and also validation with dummy data. Java ยท