About Question enthuware.ocpjp.v8.2.1886 :
Posted: Sat May 07, 2016 8:25 pm
In the code below, should "double d = allbooks.stream()" actually be "double d = bs.stream()"? Maybe I am just missing something.
Code: Select all
Given that Book is a valid class with appropriate constructor and getPrice and getTitle methods that returns a double and a String respectively, consider the following code: List<List<Book>> bs = Arrays.asList( Arrays.asList( new Book("Windmills of the Gods", 7.0), new Book("Tell me your dreams",9.0) ), Arrays.asList( new Book("There is a hippy on the highway", 5.0), new Book("Easy come easy go", 5.0)) ); double d = allbooks.stream() INSERT CODE HERE //1 INSERT CODE HERE //2 .sum(); System.out.println(d); What can be inserted in the above code so that it will print 26.0?