-
-
Save parzibyte/8e3aba867690bfceacf7eb38539cca49 to your computer and use it in GitHub Desktop.
This file contains 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 static String cadenaAleatoria(int longitud) { | |
// El banco de caracteres | |
String banco = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; | |
// La cadena en donde iremos agregando un carácter aleatorio | |
String cadena = ""; | |
for (int x = 0; x < longitud; x++) { | |
int indiceAleatorio = numeroAleatorioEnRango(0, banco.length() - 1); | |
char caracterAleatorio = banco.charAt(indiceAleatorio); | |
cadena += caracterAleatorio; | |
} | |
return cadena; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment