package com.demo; public class ContainsVowelsOrNot { public static void main(String[] args) { //first string String str = "Java"; System.out.println("Vowels is present : "+isVowelsPresent(str)); //second string str = "bcd"; System.out.println("Vowels is present : "+isVowelsPresent(str)); } private static boolean isVowelsPresent(String str) { if(str == null) { throw new IllegalArgumentException(); } return str.toLowerCase().matches(".*[aeiou].*"); }
Home »
» Program to check vowel is present in a given String or not
No comments:
Post a Comment