Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created April 14, 2021 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/143609a29c3a368f510761b553535e0c to your computer and use it in GitHub Desktop.
Save parzibyte/143609a29c3a368f510761b553535e0c to your computer and use it in GitHub Desktop.
// https://parzibyte.me/blog
public static boolean contieneSoloNumeros(String cadena) {
// Si la cadena está vacía, debemos devolver false
if (cadena.length() == 0) {
return false;
}
for (int x = 0; x < cadena.length(); x++) {
char c = cadena.charAt(x);
// Si no está entre 0 y 9
if (!(c >= '0' && c <= '9')) {
return false;
}
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment