Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 79b06fb

Browse files
Initial commit.
1 parent 0af0d7b commit 79b06fb

File tree

16 files changed

+350149
-2
lines changed

16 files changed

+350149
-2
lines changed

‎.idea/$CACHE_FILE$‎

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/$PRODUCT_WORKSPACE_FILE$‎

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/.gitignore‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/misc.xml‎

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/modules.xml‎

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/stream-api-exercises-part3.iml‎

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/vcs.xml‎

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎README.md‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
1-
# stream-api-exercises-part3
2-
Stream API Exercises : Part III
1+
### Stream API Exercises : Part III
2+
In the following exercises you will use a dictionary file: **dictionary.txt**.
3+
4+
**Q.1)** Find the words starting with letters **a** to **m**.
5+
6+
**Q.2)** Find the words starting with the letter **n** to the end of the dictionary
7+
8+
**Q.3)** Group the dictionary words by their first three letters
9+
10+
**Q.4)** Find the palindromes in the dictionary. A palindrome is a word, number, phrase, or other
11+
sequence of characters which reads the same backward as forward, such as madam or racecar
12+
13+
**Q.5)** Count the vowels used in words.
14+
15+
**Q.6)** Find the words starting with the letter **a**, and ends with the letter **z**.
16+
17+
**Q.7)** Find the longest word in the dictionary
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.example.dictionary.exercises;
2+
3+
import java.nio.file.Files;
4+
import java.nio.file.Paths;
5+
import java.util.List;
6+
7+
/**
8+
*
9+
* @author Binnur Kurt <binnur.kurt@gmail.com>
10+
*
11+
*/
12+
public class Exercise1 {
13+
14+
public static void main(String[] args) throws Exception {
15+
final List<String> words = Files.readAllLines(Paths.get("src", "dictionary.txt"));
16+
// Find the words starting with letters a to m
17+
words.stream().takeWhile(line -> line.matches("^[a-m].*$")).forEach(System.out::println);
18+
}
19+
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.example.dictionary.exercises;
2+
3+
import java.nio.file.Files;
4+
import java.nio.file.Paths;
5+
import java.util.List;
6+
7+
/**
8+
*
9+
* @author Binnur Kurt <binnur.kurt@gmail.com>
10+
*
11+
*/
12+
public class Exercise2 {
13+
14+
public static void main(String[] args) throws Exception {
15+
final List<String> words = Files.readAllLines(Paths.get("src", "dictionary.txt"));
16+
// Find the words starting with the letter n to the end of the dictionary
17+
words.stream().dropWhile(line -> line.matches("[a-m].*$")).forEach(System.out::println);
18+
}
19+
20+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /