Filtering with Streams Tutorial

From Progzoo
Jump to: navigation, search

You will need some string functions for these problems.

Does the string s contains "a"?

  s.contains("a")

Does the string s end with "y"?

  s.endsWith("y")

Does the string s have more than 6 characters?

  s.length()>6

Months with an "R"

Show the months that have an "r" in them:


[Font] [Default] [Show] [Resize] [History] [Profile]

Months ending in "ember"

Show the months that end with "ember":


[Font] [Default] [Show] [Resize] [History] [Profile]

Months short name with an "e"

Show the months that have fewer than 6 characters and contain an "e":


[Font] [Default] [Show] [Resize] [History] [Profile]

Early months with an "e"

Which of the first 6 months contains an "e" (use limit before you filter)


[Font] [Default] [Show] [Resize] [History] [Profile]

First two "ember" months

Show the first two months that end with "ember"


[Font] [Default] [Show] [Resize] [History] [Profile]

Skip 6, No "r"

Show the months with no "r". Ignore the first 6 months.


[Font] [Default] [Show] [Resize] [History] [Profile]