Java Random Char getRandomChar()

Here you can find the source of getRandomChar()

Description

get Random Char

License

Open Source License

Declaration

public static String getRandomChar() 

Method Source Code

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

import java.util.Random;

public class Main {
    public static String getRandomChar() {
        Random random = new Random();
        // Generates four random numbers, to generate a number, write a
        String[] s = { "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T",
                "U", "V", "W", "X", "Y", "Z" };
        String rand = "";
        if (random.nextBoolean()) {
            rand = String.valueOf(random.nextInt(10));
        } else {//  w w  w  . ja v a  2  s .co m
            int index = random.nextInt(25);
            rand = s[index];
        }
        return rand;
    }
}

Related

  1. createRandomChar()
  2. getRandomChar()
  3. getRandomChar()
  4. getRandomChar(boolean number, boolean lower, boolean upper, boolean other, String extra, Random _random)
  5. getRandomChar(int size)
  6. getRandomChar(int x)
  7. getRandomChar(int[][] ranges, char differentThen, boolean caseSensitive, Random random)