Write a Java program to create a method that takes a string as input and throws an exception if the string does not contain vowels

Source Code:

public class VowelCheck {
public static void checkVowel(String s) {
boolean found = false;
for(int i=0; i<s.length(); i++) {
char c = Character.toLowerCase(s.charAt(i));
if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u') {
found = true;
break;
}
}
if(!found) {
throw new RuntimeException("No vowels found in string");
}
System.out.println("Vowel found");
}

public static void main(String[] args) {
try {
checkVowel("xyz");
} catch(Exception e) {
System.out.println(e.getMessage());
}
}
}

Output: