Write a Java method that checks whether all the characters in a given string are vowels (a, e, i, o, u) or not. Return true if each character in the string is a vowel, otherwise return false.

Source Code:

public class AllVowels {
public static void main(String[] args) {
boolean result = checkAllVowels(“aeiou”);
System.out.println(result);
}

public static boolean checkAllVowels(String str) {
str = str.toLowerCase();
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
if (c != 'a' && c != 'e' && c != 'i' && c != 'o' && c != 'u') {
return false;
}
}
return true;
}
}

Output: