Learn About Random Character Generator In Brief.

Asked By 90 points N/A Posted on -
qa-featured

Hello all,

I wish to enquire about the random character generator. If any person knows about generating a random character, please tell me.

Thank you.

SHARE
Answered By 0 points N/A #299458

Learn About Random Character Generator In Brief.

qa-featured

I am not sure about the language you are using, but I am describing the process of random character generation using Java.

The easiest method is to do the following as:

  • First, create a string alphabet with the characters that you wish.
  • Suppose N = alphabet.length().
  • After that use java.util.Random class for a random integer x = nextInt(N).
  • Finally, alphabet.charAt(x) will provide you a random char from the alphabet.

For example:

Related Questions