More Java 17 by Kishori Sharan & Peter Späth
Author:Kishori Sharan & Peter Späth
Language: eng
Format: epub
ISBN: 9781484271353
Publisher: Apress
Es count: 4
The code maps the strings to IntStream. Note that the chars() method of the String class returns an IntStream, not a Stream<Character>. The output of the map() method is Stream<IntStream>. The flatMap() method maps the Stream<IntStream> to Stream<Stream<Character» and, finally, flattens it to produce a Stream<Character>. So, the output of the flatMap() method is Stream<Character>. The filter() method filters out any characters that are not an E or e. Finally, the count() method returns the number of elements in the stream. The main logic is to convert the Stream<String> to a Stream<Character>. You can achieve the same using the following code as well:long count = Stream.of("Ken", "Jeff", "Ellen")
.flatMap(name ->
IntStream.range(0, name.length())
.mapToObj(name::charAt))
.filter(ch -> ch == 'e' || ch == 'E')
.count();
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Exploring Deepfakes by Bryan Lyon and Matt Tora(7724)
Robo-Advisor with Python by Aki Ranin(7620)
Offensive Shellcode from Scratch by Rishalin Pillay(6103)
Microsoft 365 and SharePoint Online Cookbook by Gaurav Mahajan Sudeep Ghatak Nate Chamberlain Scott Brewster(5021)
Ego Is the Enemy by Ryan Holiday(4957)
Management Strategies for the Cloud Revolution: How Cloud Computing Is Transforming Business and Why You Can't Afford to Be Left Behind by Charles Babcock(4438)
Python for ArcGIS Pro by Silas Toms Bill Parker(4180)
Elevating React Web Development with Gatsby by Samuel Larsen-Disney(3886)
Machine Learning at Scale with H2O by Gregory Keys | David Whiting(3623)
Learning C# by Developing Games with Unity 2021 by Harrison Ferrone(3285)
Speed Up Your Python with Rust by Maxwell Flitton(3231)
Liar's Poker by Michael Lewis(3223)
OPNsense Beginner to Professional by Julio Cesar Bueno de Camargo(3195)
Extreme DAX by Michiel Rozema & Henk Vlootman(3172)
Agile Security Operations by Hinne Hettema(3124)
Linux Command Line and Shell Scripting Techniques by Vedran Dakic and Jasmin Redzepagic(3109)
Essential Cryptography for JavaScript Developers by Alessandro Segala(3083)
Cryptography Algorithms by Massimo Bertaccini(3001)
AI-Powered Commerce by Andy Pandharikar & Frederik Bussler(2983)
