Random generator | Sololearn: Learn to code for FREE!


Random generator

Hi, does anyone know how to make a random password generator in Java? (or a random character generator) Thanks!

10/17/2021 1:31:02 AM

Pablo Okamura Santillán

2 Answers

New Answer


There are things like RandomStringGenerator. But if you would like to make it from scratch.... The simplest way to do so, would be to make a string of all the characters you want to be in the string, and then choose random index from the string. Alternatively you could generate random int in the range of the characters you want to use(ASCII table) And then just convert it to char.


These type of questions can be easily found on the internet by just a simple search https://www.educative.io/edpresso/how-to-generate-random-numbers-in-java All the best =)