Java Random Char randomChar()

Here you can find the source of randomChar()

Description

random Char

License

Apache License

Declaration

public static char randomChar() 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static char randomChar() {
        char[] chars = { 'a', 'A', 'b', 'B', 'c', 'C', 'd', 'D', 'e', 'E', 'f', 'F', 'g', 'G', 'h', 'H', 'i', 'I',
                'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N', 'o', 'O', 'p', 'P', 'q', 'Q', 'r', 'R', 's', 'S',
                't', 'T', 'u', 'U', 'v', 'V', 'w', 'W', 'x', 'X', 'y', 'Y', 'z', 'Z' };
        int index = (int) (Math.random() * 52.0D) - 1;
        if (index < 0) {
            index = 0;/* ww  w  .  j av  a2s .com*/
        }
        return chars[index];
    }
}

Related

  1. getRandomChar(Random random, boolean upper)
  2. getRandomChar(Random random, int type)
  3. getRandomCharacter()
  4. getRandomCharacter()
  5. randomChar()
  6. randomChar()
  7. randomChar()
  8. randomChar()
  9. randomChar(char[] letters)