-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCountChList.java
33 lines (29 loc) · 1021 Bytes
/
CountChList.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import java.util.ArrayList;
import java.util.Arrays;
public class CountChList {
int print(ArrayList<String> list, char[] ch) {
int count = 0;
for (int i = 0; i < ch.length; i++) {
for (int j = 0; j < list.size(); j++) {
char[] chars = list.get(j).toLowerCase().toCharArray();
for (int k = 0; k < chars.length; k++) {
if (ch[i] == chars[k]) {
count++;
}
}
}
}
return count;
}
public static void main(String[] args) {
ArrayList<String> list = new ArrayList<>(Arrays.asList("Aniket", "Bharat", "Yash"));
char[] ch = {'a', 'e', 'i', 'o', 'u'};
CountChList countChList = new CountChList();
int intCount = countChList.print(list, ch);
if (intCount == 0) {
System.out.println("No Match Found!");
} else {
System.out.println("Vowels Count : " + intCount);
}
}
}