Created
November 6, 2019 10:30
-
-
Save y-fedorov/0e5ac798a93c478fd26f174b54a9fb6d to your computer and use it in GitHub Desktop.
Generate random Cyrillic character
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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