Ads by ProfitSence
Close

Generate a random alpha-numeric string in Java

Last Updated on Wednesday 5th Oct 2022

Java BigInteger

			
					import java.security.SecureRandom;
import java.math.BigInteger;

public class main {

  public static void main(String[] args){
     SecureRandom random = new SecureRandom();
     for( int i = 0 ; i < 5 ; i++ ){
       System.out.println(new BigInteger(65, random).toString(32));
     }
  }
}

			
	

The Above Code generates 5 random strings

			
					b1ashq3kqld8b
n6r0at8alfpg7
ut8uqsl84lt12
ta84ng5j7iiif
fr84pl4djfqo9