File tree 1 file changed +6
-15
lines changed
src/main/java/com/thealgorithms/strings 1 file changed +6
-15
lines changed Original file line number Diff line number Diff line change @@ -19,24 +19,15 @@ public class CheckVowels {
19
19
* @return {@code true} if given string has vowels, otherwise {@code false}
20
20
*/
21
21
public static boolean hasVowels (String input ) {
22
- return countVowels (input ) > 0 ;
23
- }
24
-
25
- /**
26
- * count the number of vowels
27
- *
28
- * @param input a string prints the count of vowels
29
- */
30
- public static int countVowels (String input ) {
31
22
if (input == null ) {
32
- return 0 ;
23
+ return false ;
33
24
}
34
- int cnt = 0 ;
35
- for (char c : input .toLowerCase (). toCharArray () ) {
36
- if (VOWELS .contains (c )) {
37
- ++ cnt ;
25
+ input = input . toLowerCase () ;
26
+ for (int i = 0 ; i < input .length (); i ++ ) {
27
+ if (VOWELS .contains (input . charAt ( i ) )) {
28
+ return true ;
38
29
}
39
30
}
40
- return cnt ;
31
+ return false ;
41
32
}
42
33
}
You can’t perform that action at this time.
0 commit comments