java program to check if string contains 10 digit numbers code example Example: check if string contains numbers str.matches(".*\\d.*");