Here you can find the source of randomChar()
public static char randomChar()
//package com.java2s; //License from project: Open Source License import java.util.concurrent.ThreadLocalRandom; public class Main { /**//w ww . ja v a 2 s. c o m * Generates a pseudorandom {@code char} value, from {@code 0} to * {@code 65535} inclusive. * * @return A random {@code char}. */ public static char randomChar() { return randomChar(Character.MIN_VALUE, Character.MAX_VALUE); } /** * Generates a pseudorandom {@code char} value, from the given lower bound * to the given upper bound, inclusive. * * @param lower Lower bound to generate character. * @param upper Upper bound to generate character. * @return A random {@code char}. */ public static char randomChar(int lower, int upper) { return (char) ThreadLocalRandom.current().nextInt(lower, upper + 1); } }