how to check if there is a number in a string java code example Example: check if string contains numbers str.matches(".*\\d.*");