Evalua si hay algun numero en un String

private boolean pruebaNum(String aux) { int j=0; boolean aux2=true; for (int i = 0; i < aux.length(); i++) { try { j=Integer.parseInt(""+aux.charAt(i)); break; } catch (Exception e) { // TODO: handle exception aux2=false; } } return aux2; }

1 Response

This works better with a regular expression (less lines of Code)

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.