generate 5 digit random string in java
RandomStringUtils.randomAlphanumeric(17).toUpperCase()
generate 5 digit random string in java
RandomStringUtils.randomAlphanumeric(17).toUpperCase()
how to generate random large string in java
// Java program generate a random
// UpperCase or LowerCase or Number String
import java.util.*;
public class GFG {
static String getAlphaNumericString(int n)
{
// lower limit for LowerCase Letters
int lowerLimit = 97;
// lower limit for LowerCase Letters
int upperLimit = 122;
Random random = new Random();
// Create a StringBuffer to store the result
StringBuffer r = new StringBuffer(n);
for (int i = 0; i < n; i++) {
// take a random value between 97 and 122
int nextRandomChar = lowerLimit
+ (int)(random.nextFloat()
* (upperLimit - lowerLimit + 1));
// append a character at the end of bs
r.append((char)nextRandomChar);
}
// return the resultant string
return r.toString();
}
public static void main(String[] args)
{
// size of random alphanumeric string
int n = 20;
// Get and display the alphanumeric string
System.out.println(getAlphaNumericString(n));
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us