Skip to content

Instantly share code, notes, and snippets.

@y-fedorov
Created November 6, 2019 10:30
Show Gist options
  • Save y-fedorov/0e5ac798a93c478fd26f174b54a9fb6d to your computer and use it in GitHub Desktop.
Save y-fedorov/0e5ac798a93c478fd26f174b54a9fb6d to your computer and use it in GitHub Desktop.
Generate random Cyrillic character
public class RandomStringUtils {
private static final SecureRandom RANDOM = new SecureRandom();
private static final String cyrillicCharacters = "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ";
public static String generateRandomCharacter(){
int randomCharIndex = RANDOM.nextInt(cyrillicCharacters.length());
return String.valueOf(cyrillicCharacters.charAt(randomCharIndex));
}
}
// Call
public class Application {
public static void main(String[] args) {
String ch = RandomStringUtils.generateRandomCharacter();
System.out.println("Value: " + ch);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment