This document provides an overview of Java 8 lambdas and functional programming concepts in Java. It discusses key lambda features such as functional interfaces, streams API, and method references. It also covers stream operations like filter, map, reduce, and collect, and how to parallelize stream operations. The document uses examples to illustrate how lambdas can concisely represent logic and simplify traditional iterative approaches to processing collections.
This presentaion provides and overview of the new features of Java 8, namely default methods, functional interfaces, lambdas, method references, streams and Optional vs NullPointerException.
This presentation by Arkadii Tetelman (Lead Software Engineer, GlobalLogic) was delivered at Java.io 3.0 conference in Kharkiv on March 22, 2016.
Java 8 Stream API. A different way to process collections.David Gómez García
A look on one of the features of Java 8 hidden behind the lambdas. A different way to iterate Collections. You'll never see the Collecions the same way.
These are the slides I used on my talk at the "Tech Thursday" by Oracle in June in Madrid.
Start programming in a more functional style in Java. This is the second in a two part series on lambdas and streams in Java 8 presented at the JoziJug.
This presentaion provides and overview of the new features of Java 8, namely default methods, functional interfaces, lambdas, method references, streams and Optional vs NullPointerException.
This presentation by Arkadii Tetelman (Lead Software Engineer, GlobalLogic) was delivered at Java.io 3.0 conference in Kharkiv on March 22, 2016.
Java 8 Stream API. A different way to process collections.David Gómez García
A look on one of the features of Java 8 hidden behind the lambdas. A different way to iterate Collections. You'll never see the Collecions the same way.
These are the slides I used on my talk at the "Tech Thursday" by Oracle in June in Madrid.
Start programming in a more functional style in Java. This is the second in a two part series on lambdas and streams in Java 8 presented at the JoziJug.
In this session you will learn:
List – ArrayList, LinkedList
Set – HashSet, LinkedHashSet, TreeSet
For more information: https://www.mindsmapped.com/courses/software-development/become-a-java-developer-hands-on-training/
Presentation on the new features introduced in JDK 8, presented on the 26.02.2013 in Sofia University in front of students and members of the Bulgarian java user group.
Presentation provides introduction and detailed explanation of the Java 8 Lambda and Streams. Lambda covers with Method references, default methods and Streams covers with stream operations,types of streams, collectors. Also streams are elaborated with parallel streams and benchmarking comparison of sequential and parallel streams.
Additional slides are covered with Optional, Splitators, certain projects based on lambda and streams
Functional Programming Past Present FutureIndicThreads
Presented at the IndicThreads.com Software Development Conference 2016 held in Pune, India. More at http://www.IndicThreads.com and http://Pune16.IndicThreads.com
--
Functional Programming in Java 8 - Exploiting LambdasGanesh Samarthyam
The programming world is moving towards functional programming. All the major and popular programming languages (including Java, C++, C#, Swift, and Python) support functional programming. Functional programming languages such as Clojure, Scala, and F# are on the rise. This talk introduces functional programming to those who are new to this paradigm using lambda functions in Java 8. The talk will cover syntax and semantics of lambda functions, moving from external iteration to internal iteration, and how lambda functions can result in shorter and more readable code. If you are new to functional programming and want productivity gains from using Java’s lambda functions, this talk is certainly for you.
OpenPloyer connect innovative solution providers with organizations. Together we achieve outstanding performance through fair partnerships. Offering high class HR Consulting (HCM). Experts in career counseling, recruiting, recrutainment, talent development, edutainment, neuroscience based leadership coaching, employer branding, outplacement. Gamification and Serious Games Evangelists. Gamified student advisory services, guiding parents though (online) gaming topics. We make work fun.
Gasto Symptoms is your health guide to GI related issues: colonoscopy screening, abdominal pain, heartburn, acid reflux, and other gastrointestinal symptoms
In this session you will learn:
List – ArrayList, LinkedList
Set – HashSet, LinkedHashSet, TreeSet
For more information: https://www.mindsmapped.com/courses/software-development/become-a-java-developer-hands-on-training/
Presentation on the new features introduced in JDK 8, presented on the 26.02.2013 in Sofia University in front of students and members of the Bulgarian java user group.
Presentation provides introduction and detailed explanation of the Java 8 Lambda and Streams. Lambda covers with Method references, default methods and Streams covers with stream operations,types of streams, collectors. Also streams are elaborated with parallel streams and benchmarking comparison of sequential and parallel streams.
Additional slides are covered with Optional, Splitators, certain projects based on lambda and streams
Functional Programming Past Present FutureIndicThreads
Presented at the IndicThreads.com Software Development Conference 2016 held in Pune, India. More at http://www.IndicThreads.com and http://Pune16.IndicThreads.com
--
Functional Programming in Java 8 - Exploiting LambdasGanesh Samarthyam
The programming world is moving towards functional programming. All the major and popular programming languages (including Java, C++, C#, Swift, and Python) support functional programming. Functional programming languages such as Clojure, Scala, and F# are on the rise. This talk introduces functional programming to those who are new to this paradigm using lambda functions in Java 8. The talk will cover syntax and semantics of lambda functions, moving from external iteration to internal iteration, and how lambda functions can result in shorter and more readable code. If you are new to functional programming and want productivity gains from using Java’s lambda functions, this talk is certainly for you.
OpenPloyer connect innovative solution providers with organizations. Together we achieve outstanding performance through fair partnerships. Offering high class HR Consulting (HCM). Experts in career counseling, recruiting, recrutainment, talent development, edutainment, neuroscience based leadership coaching, employer branding, outplacement. Gamification and Serious Games Evangelists. Gamified student advisory services, guiding parents though (online) gaming topics. We make work fun.
Gasto Symptoms is your health guide to GI related issues: colonoscopy screening, abdominal pain, heartburn, acid reflux, and other gastrointestinal symptoms
This slide contains short introduction to different elements of functional programming along with some specific techniques with which we use functional programming in Swift.
On March 2014, Java 8 was released. These informal slides describe the new elements of the programming languages, focusing on those taken from the functional paradigm.
Welcome to the wonderful world of Java Streams ported for the CFML world!The beauty of streams is that the elements in a stream are processed and passed across the processing pipeline. Unlike traditional CFML functions like map(), reduce() and filter() which create completely new collections until all items in the pipeline are processed. With streams, the elements are streamed across the pipeline to increase efficiency and performance.
ITB2019 CBStreams : Accelerate your Functional Programming with the power of ...Ortus Solutions, Corp
This session will introduce the cbStreams module. It will discuss what Java streams are, each of the available methods and options, and how to implement cbStreams into their applications. With real-world examples of stream implementation, this session will also show how using streams can enhance the performance of your application and reduce latency. Target Audience: Anyone wishing to learn about Java streams.
It tells about functions in C++,Types,Use,prototype,declaration,Arguments etc
function with
A function with no parameter and no return value
A function with parameter and no return value
A function with parameter and return value
A function without parameter and return value
Call by value and address
Performance van Java 8 en verder - Jeroen BorgersNLJUG
We weten allemaal dat de grootste verbetering die Java 8 brengt de ondersteuning voor lambda-expressies is. Dit introduceert functioneel programmeren in Java. Door het toevoegen van de Stream API wordt deze verbetering nog groter: iteratie kan nu intern worden afgehandeld door een bibliotheek, je kunt daarmee nu het beginsel "Tell, don’t ask" toepassen op collecties. Je kunt gewoon vertellen dat er een ??functie uitgevoerd moet worden op je verzameling, of vertellen dat dat parallel, door meerdere cores moet gebeuren. Maar wat betekent dit voor de prestaties van onze Java-toepassingen? Kunnen we nu meteen volledig al onze CPU-cores benutten om betere responstijden te krijgen? Hoe werken filter / map / reduce en parallele streams precies intern? Hoe wordt het Fork-Join framework hierin gebruikt? Zijn lambda's sneller dan inner klassen? - Al deze vragen worden beantwoord in deze sessie. Daarnaast introduceert Java 8 meer performance verbeteringen: tiered compilatie, PermGen verwijdering, java.time, Accumulators, Adders en Map verbeteringen. Ten slotte zullen we ook een kijkje nemen in de keuken van de geplande performance verbeteringen voor Java 9: benutting van GPU's, Value Types en arrays 2.0.
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 3. In this session, we will cover desktop automation along with UI automation.
Topics covered:
UI automation Introduction,
UI automation Sample
Desktop automation flow
Pradeep Chinnala, Senior Consultant Automation Developer @WonderBotz and UiPath MVP
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
Welocme to ViralQR, your best QR code generator.ViralQR
Welcome to ViralQR, your best QR code generator available on the market!
At ViralQR, we design static and dynamic QR codes. Our mission is to make business operations easier and customer engagement more powerful through the use of QR technology. Be it a small-scale business or a huge enterprise, our easy-to-use platform provides multiple choices that can be tailored according to your company's branding and marketing strategies.
Our Vision
We are here to make the process of creating QR codes easy and smooth, thus enhancing customer interaction and making business more fluid. We very strongly believe in the ability of QR codes to change the world for businesses in their interaction with customers and are set on making that technology accessible and usable far and wide.
Our Achievements
Ever since its inception, we have successfully served many clients by offering QR codes in their marketing, service delivery, and collection of feedback across various industries. Our platform has been recognized for its ease of use and amazing features, which helped a business to make QR codes.
Our Services
At ViralQR, here is a comprehensive suite of services that caters to your very needs:
Static QR Codes: Create free static QR codes. These QR codes are able to store significant information such as URLs, vCards, plain text, emails and SMS, Wi-Fi credentials, and Bitcoin addresses.
Dynamic QR codes: These also have all the advanced features but are subscription-based. They can directly link to PDF files, images, micro-landing pages, social accounts, review forms, business pages, and applications. In addition, they can be branded with CTAs, frames, patterns, colors, and logos to enhance your branding.
Pricing and Packages
Additionally, there is a 14-day free offer to ViralQR, which is an exceptional opportunity for new users to take a feel of this platform. One can easily subscribe from there and experience the full dynamic of using QR codes. The subscription plans are not only meant for business; they are priced very flexibly so that literally every business could afford to benefit from our service.
Why choose us?
ViralQR will provide services for marketing, advertising, catering, retail, and the like. The QR codes can be posted on fliers, packaging, merchandise, and banners, as well as to substitute for cash and cards in a restaurant or coffee shop. With QR codes integrated into your business, improve customer engagement and streamline operations.
Comprehensive Analytics
Subscribers of ViralQR receive detailed analytics and tracking tools in light of having a view of the core values of QR code performance. Our analytics dashboard shows aggregate views and unique views, as well as detailed information about each impression, including time, device, browser, and estimated location by city and country.
So, thank you for choosing ViralQR; we have an offer of nothing but the best in terms of QR code services to meet business diversity!
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
In this presentation, we examine the challenges and limitations of relying too heavily on PHP frameworks in web development. We discuss the history of PHP and its frameworks to understand how this dependence has evolved. The focus will be on providing concrete tips and strategies to reduce reliance on these frameworks, based on real-world examples and practical considerations. The goal is to equip developers with the skills and knowledge to create more flexible and future-proof web applications. We'll explore the importance of maintaining autonomy in a rapidly changing tech landscape and how to make informed decisions in PHP development.
This talk is aimed at encouraging a more independent approach to using PHP frameworks, moving towards a more flexible and future-proof approach to PHP development.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
2. Agenda
• Why change Java again?
• What is FP & Lambda?
• Functional Interfaces
• Streams
• Reduction
• Overloading Lambdas
• Advanced Collections and collectors
• Partioning and Grouping data
• Data Parrellelism
• Testing Lambdas
3. Why change java again
• Rise of the multicore CPUS
• Algorithms involves locks error-prone time
consuming
• Util.concurrent libraries have limititaions
• Lack of efficient parrelel operations on a
collection
• Java8 allows complex collection-processing
algorithms
4. What is fp
• Oop data abstraction/side efects
• Functional focuses on side effect free
• Pure functions/lambdas
• Pass functions around easeir to write lazy code
which initialises values when necessary
• n -> n % 2 != 0;
• (char c) -> c == 'y';
• (x, y) -> x + y;
• (int a, int b) -> a * a + b * b;
5. Functional Interfaces
• How does lambda expressions fit into Javas
type system?
• Each lambda corresponds to a given type,
specified by an interface
• exactly one abstract method declaration
• Interface with single abstract method used as
type
• Multiple optional default methods
6. Define a functional interface
@FunctionalInterface
public interface Calculator {
abstract int calculate(int x,int y);
}
public class FPDemo {
public static void main(String[] args) {
Calculator f=(x,y)->(x+y);
int z = f.calculate(3, 4);
System.out.println(z);
test((p,q)->p*q);
}
public static int test(Calculator cal) {
Return cal.calculate(4, 8);
}
7. Lambda Scopes
• int k=0;
• Calculator c1=
• (int x, int y)->
• {System.out.println(k);return x+y;};
• k=8;//fail to compile
• K is implicitly final
• Final is optional
8. Important functional interfaces in Java
• public interface Predicate<T> {
boolean test(T t);
}
• public interface Function<T,R> {
R apply(T t);
}
• public interface BinaryOperator<T> {
T apply(T left, T right);
}
public interface Consumer<T> {
void accept(T t);
}
• public interface Supplier<T> {
T get();
}
10. Functions
• Functions accept one argument and produce a
result.
• Function<String, Integer> toInteger =
Integer::valueOf;
• Function<String, Integer> toInteger=(s-
>Integer.valueOf(s);
11. Suppliers
• Suppliers produce a result of a given generic type.
Unlike Functions, Suppliers don't accept arguments.
• public class SupplierTest {
• public static void main(String[] args) {
• Supplier<SupplierTest> personSupplier =
SupplierTest::new;
• personSupplier.get(); // new Person
• }
• }
12. Consumers
• consumers represents operations to be
performed on a single input argument.
• Consumer<Person> greeter = (p) ->
System.out.println("Hello, " + p.firstName);
• greeter.accept(new Person("Luke",
"Skywalker"));
13. Comparators
• Comparator<Person> comparator = (p1, p2) ->
p1.firstName.compareTo(p2.firstName);
Person p1 = new Person("John", "Doe");
Person p2 = new Person("Alice",
"Wonderland");
• comparator.compare(p1, p2); // > 0
15. Streams
• A stream represents a sequence of elements
and supports different kind of operations to
perform computations upon those elements:
• List<String> myList =
• Arrays.asList("a1", "a2", "b1", "c2", "c1");
• myList.stream().filter(s -> s.startsWith("c"))
• .map(String::toUpperCase) .sorted()
• .forEach(System.out::println);
16. Traditional external iteration
• Int count=0;
• Iterator<Artist> iterator=allartists.iterator()
• While(iterator.hasNext())
• {Artist artist=iterator.next();
• If(artist.isForm(“NY”)
• Count++
• }
• Lot of boilerplate code and difficult concurrency
• Serial drawback
17. Internal Iterator with streams
• Long count=allartists.stream().filter(artist-
>artist.isFrom(“NY”)).count();
• Stream is tool for building up complex operations
on collections using functional approach
• If return is a stream its lazy-Intermediete stream
• If returns a value or void then its eager-Terminal
value
19. Common stream operations
• Collect(toList())
• Eager operation that genertes a list from the
values in a stream
• List<String>
collected=Stream.of("A","b","c").collect(Collec
tors.toList());
• Streams are lazy so u need eager operation
like collect
21. filter
• Assume search strings start with a digit
• Traditional style-For loop and iterate
• Functional style
• List<String>
begwithn=Stream.of(“a”,”1abc”,”abc1”).filter(v
alue->isDigit(value.charAt(0))).collect(toList());
• Predicate interface returns true/false
22. sorted
• stringCollection .stream() .sorted() .filter((s) ->
s.startsWith("a"))
.forEach(System.out::println);
• Sorted is an intermediate operation which
returns a sorted view of the stream. The
elements are sorted in natural order unless
you pass a custom Comparator.
23. Map and Match
• stringCollection .stream()
.map(String::toUpperCase) .sorted((a, b) ->
b.compareTo(a)) .forEach(System.out::println);
• boolean anyStartsWithA = stringCollection
.stream() .anyMatch((s) -> s.startsWith("a"));
24. flatmap
• Replace a value with a stream and
concantenate all streams together
• List<Integer>
together=Stream.of(Arrays.asList(1,2),Arrays.a
sList(3,4)).flatMap(numbers-
>numbers.stream()).collect(toList());
• Flatmap return type is a stream
25. Max and min
• List<Track> tracks=Arrays.asList(new
Track("track1",524),new
Track("track2",454),new
Track("track3",444));
• Track
shortesttrack=tracks.stream().min(Comparator
.comparing(track->track.getLength())).get();
• Comparing builds a comparator using keys
26. Reduction Operations
• Terminal operations ( average, sum, min, max,
and count) that return one value by combining
the contents of a stream
• reduction operations that return a collection
instead of a single value.
• general-purpose reduction operations reduce
and collect
27. Reduce
Optional<T> reduce(BinaryOperator<T> accumulator)Performs a reduction on the elements of this stream, using
an associative accumulation function, and returns an Optional describing the reduced value, if any.
T reduce(T identity, BinaryOperator<T> accumulator)Performs a reduction on the elements of this stream, using
the provided identity value and an associative accumulation function, and returns the reduced value.
<U> U reduce(U identity, BiFunction<U,? super T,U> accumulator, BinaryOperator<U> combiner)Performs a reduction on
the elements of this stream, using the provided identity, accumulation and combining functions.
29. Reduce with identity and accumilator
• Integer totalAgeReduce = roster
• .stream()
• .map(Person::getAge)
• .reduce(
• 0,
• (a, b) -> a + b);
• identity: The identity element is both the initial value of the reduction and
the default result if there are no elements in the stream
• accumulator: The accumulator function takes two parameters: a partial
result of the reduction (in this example, the sum of all processed integers
so far) and the next element of the stream (in this example, an integer).
(a, b) -> a + b
30. Generic reduce
• a reduce operation on elements of type <T> yielding a
result of type <U>
• <U> U reduce(U identity, BiFunction<U, ? super T, U>
accumulator, BinaryOperator<U> combiner);
• identity element is both an initial seed value for the
reduction and a default result if there are no input
elements
• The accumulator function takes a partial result and the
next element, and produces a new partial result
• The combiner function combines two partial results to
produce a new partial result.
31. • List<String> test= new ArrayList<String>();
• test.add("isuru");
• test.add("sam");
• test.add("silva");
• int s = test.stream().reduce(0, (x, y) -> x + y.length(), (x, y) -> x + y);
• - identity - identity value for the combiner function
- reducer - function for combining two results
- combiner - function for adding an additional element into a result.
• When you run the stream in parallel, the task is spanned into
multiple threads. So for example the data in the pipeline is
partitioned into chunks that evaluate and produce a result
independently. Then the combiner is used to merge this results.
32. Putting all together
• Get all artists for album
• Figure out which artists are bands
• Find the nationalities for each band
• Put together a set of these values
34. Stream misuse
• List<Artist>
musicians=album.getMusicians().collect(toList());
• List<Artist> bands=musicians.stream().filter(artist-
>artist.getName().startsWith(“The”)).collect(toList());
• Set<String> origins=bands.stream.map(artist-
>artist.getNationality().collect(toSet());
• Its harder to read /boiler plate code
• Less efficient because it requires eagerly creating new
collection objects in each intermediate step
• Clutters the code with intermediate variables
• Multithreading/parrelllism issues
• Chain them
36. • public void test()
• {
• overloadedm1( (y,x)->x+1);
• }
• If there are several possible target types the
most specific type is inferred
37. • private interface IntPredicate
• {
• public boolean test(int value);
• }
• public void overloadp1(Predicate<Integer> predicate)
• {
• System.out.println("Predicate");
• }
• public void overloadp1(IntPredicate predicate)
• {
• System.out.println("Intpredicate");
• }
• If there are several possible target types and there is no specific type you have to
manually provid the type
38. Binary interface compatibility
• Backward binary compatibility-If you compile
app in Java1 to 7 it will run out of the box in
Java8
• Stream method added to java8 Collection
iface
• Breaks the binary compatibility
• Not compile or Exception by Calssloader
39. Advanced Collections and Collectors
• Method references
• Artist:getName
• Artist:new
• String[] new
41. Collector
• toList ,toSet you done give the complete
implementation
• Colelcting values into a collection of specific
type
• Stream.collec(toCollection(TreeSet ::new))
42. To Values
• Collect into a single value using collector
• Finding the band with most numbers
• public Optional<Artist>
biggestGroup(Stream<Artist> artists)
• {
• Funtion<Artist,Long> getCount=artist-
>artist.getMembers().count();
• Return
artists.collect(maxBy(comparing(getCount)));
• minBy also there
43. Partioning the data
• Split out a list
• Public Map<Boolean,List<Artist>>
bandsAndsolo(Stream<Artist> artists)
• {
• return artists.collect(partitionBy(artist-
>artist.isSolo()));
• }
• Or partitionBy(Artist::isSolo) method reference
44. Grouping the data
• Grouping albums by main artist
• Public Map<Artist,List<Album>>
albumsByArtists(Stream<Album> albums)
• {
• Return albums.collect(groupingBy(album-
>album.getMainMusician()));
• }
47. Using collectors to count the number
of albums for each artist
• Public Map<Artist,Long>
numberOfalbums(Stream<Album> albums)
• {Return albums.collect(groupingBy(album-
>album.getMusician(),counting())));
• }
• This grouping devides elements into buckets
• Reduction as a collector
48. Data paralleism
• Parellism vs Concurrency
• Concurrency arises when 2 tasks are making
progress at overlapping time periods
• Parrellism arises 2 tasks are hapenning at
same time –multicore cpu
• In single cpu-concurrency
• Multi core-concurrent/parrellel
49. Data parellism..contd
• Splitting up the data to be operated on and
assigning single processing unit to each chunk
of data
• Perform same operation on a large dataset
• Task parellism-each individual thread of
execution can be doing totally different task
• Java EE container TP
50. Parellel stream operations
• Serial summing of album trak lengths
• Public int serialArraySum(){
• Return
album.stream().flatmap(Album::gettracks).mapToInt(tr
ack:getLength).sum();
• }
• Public int parreelelArraySum(){
• Return
albums.parallelstream().flatMap(Album::gettracks).ma
pToInt(Track::getLength).sum();
• When 10000 albums are hit parrel code is faster