Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

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));
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: mod 10e9+7 in java 
Java :: export java path in ubuntu 
Java :: java new string 
Java :: java make object 
Java :: how to initialize main in java 
Java :: how to hash string in java 
Java :: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:251) 
Java :: border swing 
Java :: java regex for ip address 
Java :: java system.out.println shortcut 
Java :: android get app build name 
Java :: 7877777777777777777777777 
Java :: byte array in java 
Java :: close GUI in jvava 
Java :: java use parent method 
Java :: multiple representations of the same entity are being merged 
Java :: copy text from header tag in javacript 
Java :: scaletype android dynamic 
Java :: arrondi java 
Java :: Card view only top corner radius 
Java :: increment an array java 
Java :: how to get config values bukkit 
Java :: Set icon for toolbar android 
Java :: pyramid pattern java 
Java :: Java Nested and Inner Class 
Java :: meaning of instantiated in java 
Java :: Java Create a BufferedReader 
Java :: Java Thread Example Using the Thread Class 
Java :: contain java 
Java :: java class 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =