How to check vowel is present in String in ‘Java’ ?

0 0
Read Time:20 Second

Step first we have to check in program any vowel is present in String, If it is present then output will be ‘True’ otherwise output will be ‘false’.

Write program in your compiler :
public class StringContainsVowels {

	public static void main(String[] args) {
		System.out.println(stringContainsVowels("Java")); // true
		System.out.println(stringContainsVowels("Rythm")); // false
	}

	public static boolean stringContainsVowels(String input) {
		return input.toLowerCase().matches(".*[aeiou].*");
	}

}
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Comment