Java Random randomAlpha()

Here you can find the source of randomAlpha()

Description

Generate a random character from the alphabet - either a-z or A-Z

License

Open Source License

Return

a random alphabetic character

Declaration

private static char randomAlpha() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*w  w  w .  j ava 2s. c  o m*/
     * Generate a random character from the alphabet - either a-z or A-Z
     *
     * @return a random alphabetic character
     */
    private static char randomAlpha() {
        int i = (int) (Math.random() * 52);

        if (i > 25)
            return (char) (97 + i - 26);
        else
            return (char) (65 + i);
    }
}

Related

  1. random(List list, Random random)
  2. random4DigitNumber()
  3. random_g729()
  4. random_g729()
  5. randomAgain()
  6. randomAlternate(char c)
  7. randomCharacterVector(int size)
  8. RandomCode()
  9. randomCode()