Big Java Late Objects
Big Java Late Objects
2nd Edition
ISBN: 9781119330455
Author: Horstmann
Publisher: WILEY
Expert Solution & Answer
Book Icon
Chapter 19, Problem 13RE

Explanation of Solution

“orElse” clauses in Section 19.10.2:

//Line1-Initialize the array

double[] values = . .,;

// Line 2-Compute total

double total = DoubleStream.of(values).sum();

// Line 3-Compute average

double average = DoubleStream.of(values).average().orElse(0);

// Line 4-Get largest value

double largest = DoubleStream.of(values). max(). orElse(Double.MIN_VALUE);

// Line 5-Get smallest value

Double smallest = DoubleStream.of(values). min(). orElse(Double.MAX_VALUE);

Explanation:

  • The method “orElse()” accepts any value as a “T” type parameter to return if there exists no value.
  • A specialization of “DoubleStream” is a series of double-valued elements supporting sequential and parallel aggregate operations.
  • Assume that the array “values” in line number “1” is initialized as follows,

  //Initialize the array

double[] values = {10.5,15.5,20.5,5.5};

  • The statement in line number “2” returns the sum of the array values as “52...

Blurred answer

Chapter 19 Solutions

Big Java Late 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