Big Java, Binder Ready Version: Early Objects
Big Java, Binder Ready Version: Early Objects
6th Edition
ISBN: 9781119056447
Author: Cay S. Horstmann
Publisher: WILEY
Expert Solution & Answer
Book Icon
Chapter 19, Problem 1RE

Explanation of Solution

a.

Stream<String>:

A stream is an immutable sequence of values that are processed lazily which means that accept the operations that are needed and skip the unnecessary operations. The stream library uses the lambda expressions. When using the lambda function with “Stream<String>”, the Java compiler will configure that the given object is string.

Expression to compute the number of elements starts with letter “a”:

words.filter(w -> w.startsWith("a")).count()

The “filter” method yields a stream of all elements that satisfies the given condition and “w” is the parameter variable. Here, the “startsWith()” method is used to check the prefix of a String and returns the Boolean value based on the specified letter or word. Then, the “count()” method counts the number of elements in the steam.

Explanation of Solution

b.

Expression to compute the number of elements whose length greater than ten starts with letter “a”:

words.filter(w -> w.startsWith("a")).filter(w -> w.length() > 10).count()

The “filter” method yields a stream of all elements that satisfies the given condition and “w” is the parameter variable. Here, the “startsWith()” method is used to check the prefix of a String “a” and also checks whether the length of the string is greater than “10” and the “count()” method counts the number of elements in the steam that satisfies the given condition.

Explanation of Solution

c.

Expression to compute the number of elements that limits to 100 that starts with letter “a”:

words.filter(w -> w.startsWith("a")).limit(100).count()

The “filter” method yields a stream of all elements that satisfies the given condition and “w” is the parameter variable. Here, the “startsWith()” method is used to check the prefix of a String “a” and the “limit()” method restricts the number of elements to 100. Finally, the “count()” method counts the number of elements in the steam.

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!

Chapter 19 Solutions

Big Java, Binder Ready Version: Early Objects

Ch. 19.3 - Prob. 11SCCh. 19.3 - Prob. 12SCCh. 19.3 - Prob. 13SCCh. 19.3 - Prob. 14SCCh. 19.3 - Prob. 15SCCh. 19.4 - Prob. 16SCCh. 19.4 - Prob. 17SCCh. 19.4 - Prob. 18SCCh. 19.4 - Prob. 19SCCh. 19.4 - Prob. 20SCCh. 19.5 - Prob. 21SCCh. 19.5 - Prob. 22SCCh. 19.5 - Prob. 23SCCh. 19.5 - Prob. 24SCCh. 19.5 - Prob. 25SCCh. 19.6 - Prob. 26SCCh. 19.6 - Prob. 27SCCh. 19.6 - Prob. 28SCCh. 19.6 - Prob. 29SCCh. 19.6 - Prob. 30SCCh. 19.7 - Prob. 31SCCh. 19.7 - Prob. 32SCCh. 19.7 - Prob. 33SCCh. 19.7 - Prob. 34SCCh. 19.7 - Prob. 35SCCh. 19.8 - Prob. 36SCCh. 19.8 - Prob. 37SCCh. 19.8 - Prob. 38SCCh. 19.8 - Prob. 39SCCh. 19.9 - Prob. 40SCCh. 19.9 - Prob. 41SCCh. 19.9 - Prob. 42SCCh. 19.9 - Prob. 43SCCh. 19.9 - Prob. 44SCCh. 19.10 - Prob. 45SCCh. 19.10 - Prob. 46SCCh. 19.10 - Prob. 47SCCh. 19.10 - Prob. 48SCCh. 19.10 - Prob. 49SCCh. 19 - Prob. 1RECh. 19 - Prob. 2RECh. 19 - Prob. 3RECh. 19 - Prob. 4RECh. 19 - Prob. 5RECh. 19 - Prob. 6RECh. 19 - Prob. 7RECh. 19 - Prob. 8RECh. 19 - Prob. 9RECh. 19 - Prob. 10RECh. 19 - Prob. 11RECh. 19 - Prob. 12RECh. 19 - Prob. 13RECh. 19 - Prob. 1PECh. 19 - Prob. 2PECh. 19 - Prob. 3PECh. 19 - Prob. 4PECh. 19 - Prob. 5PECh. 19 - Prob. 6PECh. 19 - Prob. 7PECh. 19 - Prob. 8PECh. 19 - Prob. 9PECh. 19 - Prob. 10PECh. 19 - Prob. 11PECh. 19 - Prob. 12PECh. 19 - Prob. 13PECh. 19 - Prob. 14PECh. 19 - Prob. 15PECh. 19 - Prob. 16PECh. 19 - Prob. 17PECh. 19 - Prob. 18PECh. 19 - Prob. 19PECh. 19 - Prob. 20PECh. 19 - Prob. 1PPCh. 19 - Prob. 2PPCh. 19 - Prob. 3PPCh. 19 - Prob. 4PPCh. 19 - Prob. 5PPCh. 19 - Prob. 6PPCh. 19 - Prob. 7PPCh. 19 - Prob. 8PPCh. 19 - Prob. 9PPCh. 19 - Prob. 10PPCh. 19 - Prob. 11PPCh. 19 - Prob. 12PP
Knowledge Booster
Background pattern image
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education