There's a revolution calling! Lambda expressions are coming in Java 8 but how can developers benefit? We'll go through a series of code examples, that show how to:
Use the new lambda expressions feature
Write more readable and faster collections processing code using the Streams API
Build complex data processing systems with the new collector abstraction
Use lambda expressions in your own code
There's a revolution calling! Lambda expressions are coming in Java 8 but how can developers benefit? We'll go through a series of code examples, that show how to:
Use the new lambda expressions feature
Write more readable and faster collections processing code using the Streams API
Build complex data processing systems with the new collector abstraction
Use lambda expressions in your own code
Evolving with Java - How to remain Relevant and EffectiveNaresha K
Slides from my GIDS 2019 presentation - Evolving with Java - How to remain relevant and effective. In this presentation, I share examples of evolving with Java to overcome the pain points.
Awareness of design smells - indicators of common design problems - helps developers or software engineers understand mistakes made while designing and apply design principles for creating high-quality designs. This workshop provides insights gained from performing refactoring in real-world projects to improve refactoring and reduce the time and costs of managing software projects. The workshop also presents insightful anecdotes and case studies drawn from the trenches of real-world projects. By attending this workshop, you will know pragmatic techniques for refactoring design smells to manage technical debt and to create and maintain high-quality software in practice.
Contents overview:
* Why care about design principles, design quality, or design smells?
* Refactoring as the primary means for repaying technical debt
* Smells that violate abstraction, encapsulation, modularisation, or hierarchy
* Tools and techniques for refactoring
Lambdas and Streams Master Class Part 2José Paumard
These are the slides of the talk we made with Stuart Marks at Devoxx Belgium 2018. This second part covers the Stream API, reduction and the Collector API.
What is the state of lambda expressions in Java 11? Lambda expressions are the major feature of Java 8, having an impact on most of the API, including the Streams and Collections API. We are now living the Java 11 days; new features have been added and new patterns have emerged. This highly technical Deep Dive session will visit all these patterns, the well-known ones and the new ones, in an interactive hybrid of lecture and laboratory. We present a technique and show how it helps solve a problem. We then present another problem, and give you some time to solve it yourself. Finally, we present a solution, and open for questions, comments, and discussion. Bring your laptop set up with JDK 11 and your favorite IDE, and be prepared to think!
The slides of my talk at Devoxx BE 2017. This in depth talk is all about collectors: those available, because we need to know them, those that we can create, those we had no idea they could be created, and the others, as there is in fact no limit to what can be done with this API. The concept of downstream collector will be used to show how we can write entire data processing pipelines using collectors only, and pass them as parameters to other pipelines.
The presentation from SPb Python Interest Group community meetup.
The presentation tells about the dictionaries in Python, reviews the implementation of dictionary in CPython 2.x, dictionary in CPython 3.x, and also recent changes in CPython 3.6. In addition to CPython the dictionaries in alternative Python implementations such as PyPy, IronPython and Jython are reviewed.
This presentation is from the 22nd Tcl Conference (Manassas, VA, 21-23 October 2015). It's where I describe where we've got up to with compiling Tcl to native machine code.
You may be hearing a lot of buzz around functional programming. For example, Java 8 recently introduced new features (lambda expressions and method references) and APIs (Streams, Optional and CompletableFutures) inspired from functional ideas such as first-class functions, composition and immutability.
However, what does this mean for my existing codebase?
In this talk we show how you can refactor your traditional object-oriented Java to using FP features and APIs from Java 8 in a beneficial manner.
We will discuss:
- How to adapt to requirement changes using first-class functions
- How you can enhance code reusability using currying
- How you can make your code more robust by favouring immutability over mutability
- How you can design better APIs and reduce unintended null pointer exceptions using an optional data type"
JavaScript Fundamentals with Angular and LodashBret Little
The purpose of this presentation is also largely to explain some of the fun parts of JavaScript (dynamic function invocation with reflection, dynamic arguments, etc). I don't necessarily encourage putting complex logic throughout your templates with lodash, though there may be times it is appropriate.
Lets talk about lodash and how it can easily be married to Angular. Using a six line filter, I will expose the power of lodash directly within angular templates. This will be an introduction to lodash, angular templates, and we'll talk about scope and reflection within JavaScript.
Evolving with Java - How to remain Relevant and EffectiveNaresha K
Slides from my GIDS 2019 presentation - Evolving with Java - How to remain relevant and effective. In this presentation, I share examples of evolving with Java to overcome the pain points.
Awareness of design smells - indicators of common design problems - helps developers or software engineers understand mistakes made while designing and apply design principles for creating high-quality designs. This workshop provides insights gained from performing refactoring in real-world projects to improve refactoring and reduce the time and costs of managing software projects. The workshop also presents insightful anecdotes and case studies drawn from the trenches of real-world projects. By attending this workshop, you will know pragmatic techniques for refactoring design smells to manage technical debt and to create and maintain high-quality software in practice.
Contents overview:
* Why care about design principles, design quality, or design smells?
* Refactoring as the primary means for repaying technical debt
* Smells that violate abstraction, encapsulation, modularisation, or hierarchy
* Tools and techniques for refactoring
Lambdas and Streams Master Class Part 2José Paumard
These are the slides of the talk we made with Stuart Marks at Devoxx Belgium 2018. This second part covers the Stream API, reduction and the Collector API.
What is the state of lambda expressions in Java 11? Lambda expressions are the major feature of Java 8, having an impact on most of the API, including the Streams and Collections API. We are now living the Java 11 days; new features have been added and new patterns have emerged. This highly technical Deep Dive session will visit all these patterns, the well-known ones and the new ones, in an interactive hybrid of lecture and laboratory. We present a technique and show how it helps solve a problem. We then present another problem, and give you some time to solve it yourself. Finally, we present a solution, and open for questions, comments, and discussion. Bring your laptop set up with JDK 11 and your favorite IDE, and be prepared to think!
The slides of my talk at Devoxx BE 2017. This in depth talk is all about collectors: those available, because we need to know them, those that we can create, those we had no idea they could be created, and the others, as there is in fact no limit to what can be done with this API. The concept of downstream collector will be used to show how we can write entire data processing pipelines using collectors only, and pass them as parameters to other pipelines.
The presentation from SPb Python Interest Group community meetup.
The presentation tells about the dictionaries in Python, reviews the implementation of dictionary in CPython 2.x, dictionary in CPython 3.x, and also recent changes in CPython 3.6. In addition to CPython the dictionaries in alternative Python implementations such as PyPy, IronPython and Jython are reviewed.
This presentation is from the 22nd Tcl Conference (Manassas, VA, 21-23 October 2015). It's where I describe where we've got up to with compiling Tcl to native machine code.
You may be hearing a lot of buzz around functional programming. For example, Java 8 recently introduced new features (lambda expressions and method references) and APIs (Streams, Optional and CompletableFutures) inspired from functional ideas such as first-class functions, composition and immutability.
However, what does this mean for my existing codebase?
In this talk we show how you can refactor your traditional object-oriented Java to using FP features and APIs from Java 8 in a beneficial manner.
We will discuss:
- How to adapt to requirement changes using first-class functions
- How you can enhance code reusability using currying
- How you can make your code more robust by favouring immutability over mutability
- How you can design better APIs and reduce unintended null pointer exceptions using an optional data type"
JavaScript Fundamentals with Angular and LodashBret Little
The purpose of this presentation is also largely to explain some of the fun parts of JavaScript (dynamic function invocation with reflection, dynamic arguments, etc). I don't necessarily encourage putting complex logic throughout your templates with lodash, though there may be times it is appropriate.
Lets talk about lodash and how it can easily be married to Angular. Using a six line filter, I will expose the power of lodash directly within angular templates. This will be an introduction to lodash, angular templates, and we'll talk about scope and reflection within JavaScript.
The JVM was initially designed to support only Java programming language. However, as time passed, more languages were adapted or designed to run on the Java platform. As time passes, these languages are being more dominant factor to influence the ultimate fate of the JVM in future.
Presented in JUGBD Meetup 5.0 held in Dhaka.
Meet Ramda, a functional programming helper library which can replace Lodash and Underscore in various use-cases. Ramda is all curried and adds various facilities for increasing code reuse.
Evolving with Java - How to Remain EffectiveNaresha K
Slides from my Java2Days 2020 talk - "Evolving with Java - How to Remain Effective".
Developers find themselves in need to continually update themselves with the rapidly changing technologies to remain relevant and deliver value. However, by keeping a few things in mind and with certain practices, this can be a pleasant experience. In this presentation, I share my experiences learning and evolving with Java in the last 15+ years. The ideas presented are generic enough to be applicable for people using any technology stack. However, the code examples are in Java/ JVM languages.
We start by understanding the importance of gradual improvement. To keep motivated for continuous improvement, in my experience, responsiveness is a vital element. I share my experience of how to increase your responsiveness. To be able to change/ experiment continuously in our code, we need to ensure that we don't break anything. We explore the necessary techniques to achieve safety. Often we mistakenly consider lack of familiarity as complexity. We explore options to come out of this confusion. We then touch upon the impact of learning paradigms and multiple languages available on the JVM. Finally, we touch upon another important aspect of continuous improvement that is unlearning. We conclude the session by summarising the principles.
Java 8 came out early last year and Java 7 is now, at the end of life, making Java 8 the only Oracle supported option. However, since developers value stability over trendiness, many of us are still working with Java 7, or even 6. Let’s look at some features of Java 8, and provide some arguments to persuade your code to upgrade with best practices.
Java 8 came out early last year and Java 7 is now, at the end of life, making Java 8 the only Oracle supported option. However, since developers value stability over trendiness, many of us are still working with Java 7, or even 6. Let’s look at some features of Java 8, and provide some arguments to persuade your code to upgrade with best practices.
Java 8 came out early last year and Java 7 is now, at the end of life, making Java 8 the only Oracle supported option. However, since developers value stability over trendiness, many of us are still working with Java 7, or even 6. Let’s look at some features of Java 8, and provide some arguments to persuade your code to upgrade with best practices.
Lazy Java by Mario Fusco
Like all imperative languages Java is, with some minor but notable exceptions, an eagerly evaluated programming language. Nevertheless the introduction of lambdas in Java 8 also allowed the adoption of some lazy patterns and data structures that are more typically employed in functional languages. Streams represent the most evident example of how also native Java API has taken advantage of laziness, but there is a number of other interesting scenarios where laziness can be an effective solution to quite common problems. In fact laziness is the only possible technique to process potentially infinite amount of data, or more in general to delay the expensive evaluation of an expression only when and if it is necessary. But laziness is even more than that: for instance the reader monad delays not only a computation but also the need of external dependencies thus lowering the abuse of dependency injection, while a trampoline uses laziness to delay and then linearize recursive calls preventing the overflow of the stack. The purpose of this talk is illustrating why and how implementing laziness in Java with practical examples delivered with both slides and live coding sessions.
Mario Fusco - Lazy Java - Codemotion Milan 2018Codemotion
Like all imperative languages Java is eagerly evaluated, but the introduction of lambdas allowed the adoption of some lazy patterns and data structures that are typically functional. Streams are the most evident example of a native Java API using laziness, but there are other cases where laziness is an effective solution to common problems. In fact it makes possible to process infinite amount of data, but it is even more than that. This talk shows why and how implementing laziness in Java with practical examples delivered with both slides and live coding sessions.
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisGlobus
JASMIN is the UK’s high-performance data analysis platform for environmental science, operated by STFC on behalf of the UK Natural Environment Research Council (NERC). In addition to its role in hosting the CEDA Archive (NERC’s long-term repository for climate, atmospheric science & Earth observation data in the UK), JASMIN provides a collaborative platform to a community of around 2,000 scientists in the UK and beyond, providing nearly 400 environmental science projects with working space, compute resources and tools to facilitate their work. High-performance data transfer into and out of JASMIN has always been a key feature, with many scientists bringing model outputs from supercomputers elsewhere in the UK, to analyse against observational or other model data in the CEDA Archive. A growing number of JASMIN users are now realising the benefits of using the Globus service to provide reliable and efficient data movement and other tasks in this and other contexts. Further use cases involve long-distance (intercontinental) transfers to and from JASMIN, and collecting results from a mobile atmospheric radar system, pushing data to JASMIN via a lightweight Globus deployment. We provide details of how Globus fits into our current infrastructure, our experience of the recent migration to GCSv5.4, and of our interest in developing use of the wider ecosystem of Globus services for the benefit of our user community.
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Globus
The U.S. Geological Survey (USGS) has made substantial investments in meeting evolving scientific, technical, and policy driven demands on storing, managing, and delivering data. As these demands continue to grow in complexity and scale, the USGS must continue to explore innovative solutions to improve its management, curation, sharing, delivering, and preservation approaches for large-scale research data. Supporting these needs, the USGS has partnered with the University of Chicago-Globus to research and develop advanced repository components and workflows leveraging its current investment in Globus. The primary outcome of this partnership includes the development of a prototype enterprise repository, driven by USGS Data Release requirements, through exploration and implementation of the entire suite of the Globus platform offerings, including Globus Flow, Globus Auth, Globus Transfer, and Globus Search. This presentation will provide insights into this research partnership, introduce the unique requirements and challenges being addressed and provide relevant project progress.
Enhancing Research Orchestration Capabilities at ORNL.pdfGlobus
Cross-facility research orchestration comes with ever-changing constraints regarding the availability and suitability of various compute and data resources. In short, a flexible data and processing fabric is needed to enable the dynamic redirection of data and compute tasks throughout the lifecycle of an experiment. In this talk, we illustrate how we easily leveraged Globus services to instrument the ACE research testbed at the Oak Ridge Leadership Computing Facility with flexible data and task orchestration capabilities.
Unleash Unlimited Potential with One-Time Purchase
BoxLang is more than just a language; it's a community. By choosing a Visionary License, you're not just investing in your success, you're actively contributing to the ongoing development and support of BoxLang.
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTier1 app
Even though at surface level ‘java.lang.OutOfMemoryError’ appears as one single error; underlyingly there are 9 types of OutOfMemoryError. Each type of OutOfMemoryError has different causes, diagnosis approaches and solutions. This session equips you with the knowledge, tools, and techniques needed to troubleshoot and conquer OutOfMemoryError in all its forms, ensuring smoother, more efficient Java applications.
Globus Connect Server Deep Dive - GlobusWorld 2024Globus
We explore the Globus Connect Server (GCS) architecture and experiment with advanced configuration options and use cases. This content is targeted at system administrators who are familiar with GCS and currently operate—or are planning to operate—broader deployments at their institution.
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar
The European Union Agency for Law Enforcement Cooperation (Europol) has suffered an alleged data breach after a notorious threat actor claimed to have exfiltrated data from its systems. Infamous data leaker IntelBroker posted on the even more infamous BreachForums hacking forum, saying that Europol suffered a data breach this month.
The alleged breach affected Europol agencies CCSE, EC3, Europol Platform for Experts, Law Enforcement Forum, and SIRIUS. Infiltration of these entities can disrupt ongoing investigations and compromise sensitive intelligence shared among international law enforcement agencies.
However, this is neither the first nor the last activity of IntekBroker. We have compiled for you what happened in the last few days. To track such hacker activities on dark web sources like hacker forums, private Telegram channels, and other hidden platforms where cyber threats often originate, you can check SOCRadar’s Dark Web News.
Stay Informed on Threat Actors’ Activity on the Dark Web with SOCRadar!
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Anthony Dahanne
Les Buildpacks existent depuis plus de 10 ans ! D’abord, ils étaient utilisés pour détecter et construire une application avant de la déployer sur certains PaaS. Ensuite, nous avons pu créer des images Docker (OCI) avec leur dernière génération, les Cloud Native Buildpacks (CNCF en incubation). Sont-ils une bonne alternative au Dockerfile ? Que sont les buildpacks Paketo ? Quelles communautés les soutiennent et comment ?
Venez le découvrir lors de cette session ignite
Listen to the keynote address and hear about the latest developments from Rachana Ananthakrishnan and Ian Foster who review the updates to the Globus Platform and Service, and the relevance of Globus to the scientific community as an automation platform to accelerate scientific discovery.
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...Juraj Vysvader
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I didn't get rich from it but it did have 63K downloads (powered possible tens of thousands of websites).
How to Position Your Globus Data Portal for Success Ten Good PracticesGlobus
Science gateways allow science and engineering communities to access shared data, software, computing services, and instruments. Science gateways have gained a lot of traction in the last twenty years, as evidenced by projects such as the Science Gateways Community Institute (SGCI) and the Center of Excellence on Science Gateways (SGX3) in the US, The Australian Research Data Commons (ARDC) and its platforms in Australia, and the projects around Virtual Research Environments in Europe. A few mature frameworks have evolved with their different strengths and foci and have been taken up by a larger community such as the Globus Data Portal, Hubzero, Tapis, and Galaxy. However, even when gateways are built on successful frameworks, they continue to face the challenges of ongoing maintenance costs and how to meet the ever-expanding needs of the community they serve with enhanced features. It is not uncommon that gateways with compelling use cases are nonetheless unable to get past the prototype phase and become a full production service, or if they do, they don't survive more than a couple of years. While there is no guaranteed pathway to success, it seems likely that for any gateway there is a need for a strong community and/or solid funding streams to create and sustain its success. With over twenty years of examples to draw from, this presentation goes into detail for ten factors common to successful and enduring gateways that effectively serve as best practices for any new or developing gateway.
Software Engineering, Software Consulting, Tech Lead.
Spring Boot, Spring Cloud, Spring Core, Spring JDBC, Spring Security,
Spring Transaction, Spring MVC,
Log4j, REST/SOAP WEB-SERVICES.
Navigating the Metaverse: A Journey into Virtual Evolution"Donna Lenk
Join us for an exploration of the Metaverse's evolution, where innovation meets imagination. Discover new dimensions of virtual events, engage with thought-provoking discussions, and witness the transformative power of digital realms."
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns
Unlocking Business Potential: Tailored Technology Solutions by Prosigns
Discover how Prosigns, a leading technology solutions provider, partners with businesses to drive innovation and success. Our presentation showcases our comprehensive range of services, including custom software development, web and mobile app development, AI & ML solutions, blockchain integration, DevOps services, and Microsoft Dynamics 365 support.
Custom Software Development: Prosigns specializes in creating bespoke software solutions that cater to your unique business needs. Our team of experts works closely with you to understand your requirements and deliver tailor-made software that enhances efficiency and drives growth.
Web and Mobile App Development: From responsive websites to intuitive mobile applications, Prosigns develops cutting-edge solutions that engage users and deliver seamless experiences across devices.
AI & ML Solutions: Harnessing the power of Artificial Intelligence and Machine Learning, Prosigns provides smart solutions that automate processes, provide valuable insights, and drive informed decision-making.
Blockchain Integration: Prosigns offers comprehensive blockchain solutions, including development, integration, and consulting services, enabling businesses to leverage blockchain technology for enhanced security, transparency, and efficiency.
DevOps Services: Prosigns' DevOps services streamline development and operations processes, ensuring faster and more reliable software delivery through automation and continuous integration.
Microsoft Dynamics 365 Support: Prosigns provides comprehensive support and maintenance services for Microsoft Dynamics 365, ensuring your system is always up-to-date, secure, and running smoothly.
Learn how our collaborative approach and dedication to excellence help businesses achieve their goals and stay ahead in today's digital landscape. From concept to deployment, Prosigns is your trusted partner for transforming ideas into reality and unlocking the full potential of your business.
Join us on a journey of innovation and growth. Let's partner for success with Prosigns.
2. Who We are
Bazlur Rahman Rokon
Associate Software Engineer, Therap Services, LLC
Sazzadur Rahman
Software Engineer, Kona Software Lab Ltd.
3. What’s new in Java 8
1. Lambda Expressions
2. Method references
3. Default methods
4. Bulk Data Operation → Stream API
5. Date-Time
6. And a lot more ……
4. Assumption
1. We really love abstraction
2. We Actually Build cool Stuffs
3. We are programmers and lazy
4. We work only day time and go home early (Well, we have life, right
:/ )
5. Users want too many features
6. As we are lazy, we don’t want to do too much work.
7. So we love “Less code, do more” philosophy
5. The Best Code is No Code At All
1. Code is bad
2. It rots
3. It requires periodic maintenance
4. But the fact is, we love coding, more specifically less
coding
13. What is Lambda Expression
(Thing t ) -> { }
(Thing t , More m) -> { }
14. Let’s have a situation
public class Person {
private String name;
private LocalDate birthday;
private Sex gender;
private String emailAddress;
private String cellNo;
// getters and setters//
15. What we want to do
1. Search based on characteristics and send
email/call
1. find older than 60 -> then need Elderly allowance
2. find voters
1. kids -> less than 18 -> they are not allowed to
vote, so ignore them
2. sort by name, by age
16. Take # 1
public void findPersonOlder(List<Person> persons) {
for (Person p : persons) {
if (p.getAge() > 60) {
sendEmail(p.getEmailAddress());
}
}
}
17. Take #2
public void findEligibleVoters(List<Person> persons) {
for (Person p : persons) {
if (p.getAge() > 18) {
sendEmail(p.getEmailAddress());
}
}
}
18. Take # 3
public void findTargetAudienceForAd(List<Person> persons) {
for (Person p : persons) {
if (p.getAge() > 25 &&
p.getGender() == Sex.MALE) {
sendEmail(p.getEmailAddress());
}
}
}
19. A lots of combinations
We can keep going on and on and
on….
20. Lets parameterize the behavior
public interface PersonPredicate {
public boolean testPerson(Person p);
}
21. public void processPerson(List<Person> persons,
PersonPredicate predicate) {
for (Person p : persons) {
if (predicate.testPerson(p)) {
sendEmail(p.getEmailAddress());
}
}
}
23. Revisit Take #3
processPerson(persons, new PersonPredicate() {
@Override
public boolean testPerson(Person p) {
return p.getAge() > 25 &&
p.getGender() == Sex.MALE;
}
});
24. We want to call as well
public interface PersonConsumer {
public void accept (String phoneNumber);
}
25. public void processPerson(List<Person> persons,
PersonPredicate predicate,
PersonConsumer consumer) {
for (Person p : persons) {
if (predicate.testPerson(p)) {
String cellNo = p.getCellNo();
consumer.accept(cellNo);
}
}
}
26. Lets put it a bit harder
public void processPerson(List<Person> persons,
PersonPredicate predicate,
PersonConsumer consumer) {
for (Person p : persons) {
if (predicate.testPerson(p)) {
String cellNo = p.getCellNo();
consumer.accept(cellNo);
}
}
}
40. What is Stream?
•A sequence of elements from a source supporting sequential and parallel
aggregate operations, While completely abstracting the details of low level
multi threading logic.
•Sources can be Any type of Collection, Array, or any I/O operation who
provides data to the Stream.
•Aggregate operations are operations to collect or extract necessary
information from a stream or collection.
41. What is Stream?
persons
.stream()
.filter(p-> p.getAge()>19)
.map(p-> p.getCellNo())
.forEach( c-> call(c));
Intermdediate Operation
Terminal Operation
Get Stream
Source
Pipelining
Intermdediate Operation
45. allMatch and noneMatch
//Check if All of the students have distinction
Boolean hasAllStudentsWithDistinction = students.stream()
.allMatch(student -> student.getScore() > 80);
//Return true if None of the students are over distinction
Boolean hasAllStudentsBelowDistinction = students.stream()
.noneMatch(student -> student.getScore() > 80);
46. Reduce
Reduces the whole stream into a single value
//Summing all elements of a stream
Integer sum = numbers.stream()
.reduce(0, (x, y) -> x + y); //reduce(identity, accumulator)
Integer min = numbers.stream()
.reduce(0, Integer::min);
47. What about having no terminal
Operation?
persons
.stream()
.filter(p-> p.getAge()>19)
.map(p-> p.getCellNo())
Intermdediate Operation
Get Stream
Source
Pipelining Intermdediate Operation
48. Lazy and Eager
Did you scrolled your facebook timeline, down to the beginning?
49. Laziness of Stream operations
• Current era is of Big Data, Parallel Processing and being real time.
• When dealing with Big Data Laziness is a big deal.
• Stream API is inherently Lazy and based on “Process on Demand”
behavior.
50. Laziness of Stream operations
Stream<String> streamOfNames = students.stream()
.map(student -> {
System.out.println("In Map - " +
student.getName());
return student.getName();
});
//Just to add some delay
for (int i = 1; i <= 5; i++) {
Thread.sleep(1000);
System.out.println(i + " sec");
}
//Called a terminal operation on the stream
streamOfNames.collect(Collectors.toList());
Output:
1 sec
2 sec
3 sec
4 sec
5 sec
In Map - Tom
In Map - Chris
In Map - Dave
51. Short Circuit
//List of first 3 students who have age > 20
students.stream()
.filter(s -> s.getAge() > 20)
.map(Student::getName)
.limit(3)
.collect(Collectors.toList());