Java check whether string contains vowels

Java check whether string contains vowels

how to find the vowels in a given string in java

/**
 * @author lautturi.com
 * Java example: check if vowel present in string java
 */

import java.util.*;

public class Lautturi {
	public static void main(String[] args) {

		String str = new String("Hello lautturi Java world!");
	      for(int i=0; i<str.length(); i++) {
	         if(str.charAt(i) == 'a'|| str.charAt(i) == 'e'|| str.charAt(i) == 'i' || str.charAt(i) == 'o' || str.charAt(i) == 'u'
	        	|| str.charAt(i) == 'A'|| str.charAt(i) == 'E'|| str.charAt(i) == 'I' || str.charAt(i) == 'O' || str.charAt(i) == 'U') {
	            System.out.println("The string contains vowel "+str.charAt(i)+" at the position "+i);
	         }
	      }
	}
}
Source‮l.www:‬autturi.com

output:

The string contains vowel e at the position 1
The string contains vowel o at the position 4
The string contains vowel a at the position 7
The string contains vowel u at the position 8
The string contains vowel u at the position 11
The string contains vowel i at the position 13
The string contains vowel a at the position 16
The string contains vowel a at the position 18
The string contains vowel o at the position 21
Created Time:2017-09-02 22:18:41  Author:lautturi