forked from sumeet-automation/selenium-java-interview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuestion34.java
More file actions
24 lines (19 loc) · 695 Bytes
/
Copy pathQuestion34.java
File metadata and controls
24 lines (19 loc) · 695 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package string;
import java.util.List;
import java.util.regex.Pattern;
import static java.util.stream.Collectors.toSet;
public class Question34 {
public static void main(String[] args) {
var word = "HELLO, HOW ARE YOu";
var vowels = List.of("A", "E", "I", "O", "U");
//Print the count of vowels
//Stream.of(word.split(""))
System.out.println(Pattern.compile("").splitAsStream(word)
.map(String::toUpperCase).filter(vowels::contains).collect(toSet()));
for (String letter : word.split("")) {
if (vowels.contains(letter.toUpperCase())) {
System.out.print(letter);
}
}
}
}