Slides aim to provide constructed information about functional programming in Java 8. To able to do that, Lambdas, Built-in Functional Interfaces and Optionals summarised with code examples.
This is an intermediate conversion course for C++, suitable for second year computing students who may have learned Java or another language in first year.
This document summarizes a lecture on operators and expressions in Java. It discusses the four main categories of operators: arithmetic, bitwise, relational, and logical. It provides examples of common operators like addition, subtraction, logical AND, OR, and describes operator precedence. Key concepts covered include arithmetic assignment operators, increment/decrement operators, bitwise operators, relational operators for comparison, short-circuit logical operators, and the ternary conditional operator.
The document discusses new features introduced in Java 8, including allowing static and default methods in interfaces, lambda expressions, and the Stream API. Key points include: interfaces can now contain static and default methods; lambda expressions provide a concise way to implement functional interfaces and allow passing code as a method argument; and the Stream API allows operations on sequences of data through intermediate and terminal operations.
This document discusses functions in C++. It explains that functions allow code to be reused without copying, make changes easier, and keep code organized. It provides examples of common functions like sqrt() and rand(). It outlines that a function has a prototype defining its return type, name, and parameters, and a definition containing the code. Prototypes declare a function before main() so it can be called. Return types specify what is returned. Examples demonstrate full function declarations before main().
This is an intermediate conversion course for C++, suitable for second year computing students who may have learned Java or another language in first year.
This document discusses computer science functions and their key concepts:
- Functions are subroutines or blocks of code that perform a specific task and can be reused. They take parameters as inputs and return an output.
- The interface of a function defines what it can do from the outside, while the implementation contains the internal code that carries out its behavior.
- Pure functions always return the same output for given inputs, while impure functions may produce side effects or different outputs for the same inputs.
- Examples demonstrate defining functions with and without parameters, recursive functions, and using functions to solve problems like determining if a number is even or odd.
Recursion is a fundamental programming technique where a method calls itself to solve a problem. This chapter discusses recursive thinking and programming, providing examples of recursion in sorting, graphics, and solving puzzles like the Towers of Hanoi. Some key algorithms covered are merge sort, quick sort, maze traversal, and generating fractals. Recursive solutions can provide elegant code but require careful structuring to avoid infinite recursion.
Implicit conversions occur when expressions have mixed types or function arguments do not match the function prototype. The compiler first tries a trivial conversion, then promotion, then a built-in type conversion, then a user-defined conversion, generating an error if none match. User-defined conversions are checked to see if the type needed has a defined conversion and if the supplied type matches or can be promoted. At most one built-in and one user-defined conversion will be applied. Explicit conversions occur when a cast is used, creating a temporary object that is destroyed after the statement.
Java provides a rich set of operators that are divided into arithmetic, relational, bitwise, logical, and assignment operators. These operators allow mathematical and logical manipulation of variables and values in Java programs. The document then proceeds to describe each type of operator in detail providing examples of their usage.
This document summarizes operators and expressions in Java. It discusses the four main categories of operators: arithmetic, bitwise, relational, and logical. For each category, it provides examples of the different operators and how they work. The key points covered include:
- Arithmetic operators like +, -, *, /, % that perform math operations.
- Bitwise operators like &, |, ^ that operate on individual bits.
- Relational operators like ==, !=, <, > that compare values and return a boolean.
- Logical operators like &&, ||, ! that combine boolean expressions.
- Assignment operators like = that store values in variables.
- Special operators
This document provides an agenda for a Java 8 training session that covers Lambdas and functional interfaces, the Stream API, default and static methods in interfaces, Optional, the new Date/Time API, and Nashorn JavaScript engine. It includes sections on Lambda expressions and method references syntax, functional interfaces, built-in functional interfaces, streams versus collections, using Optional to avoid null checks, extending interfaces with default methods, and key concepts of the new Date/Time and Nashorn JavaScript APIs.
Scala is a hybrid language that blends object-oriented and functional programming. It is statically typed and runs on the JVM. Scala has classes, objects, traits, and supports immutability, concurrency with actors, and pattern matching. Functions are first-class citizens and can be passed as parameters or returned from methods.
This document discusses algebraic specification, which specifies an object class or type in terms of the relationships between its defined operations. An algebraic specification defines a system as a heterogeneous algebra consisting of different sets with defined operations. It describes the types, syntax, equations, and properties of algebraic specifications. Advantages are that they are unambiguous, precise, and allow studying the effects of operations, while disadvantages are that ensuring completeness is difficult.
In this lesson, we will start by defining the basic concept related to Pyhton: operations, variables, and basic types.
Then we will define the concept of a function, and how to use it.
[Notebook link]( https://drive.google.com/file/d/1T4T32lyCkT4J992tfnKUADQU88Qvlrvc/view?usp=drivesdk)
Finally, we will explain the concept of modules and libraries. And, we will show how to install these libraries in Google Colab.
The document discusses various operators in Java including mathematical, assignment, increment/decrement, relational, logical, ternary, string and casting operators. It provides examples of using each operator and notes precedence rules and other behaviors like type promotion and truncation versus rounding during casting.
Functions are blocks of reusable code that perform specific tasks. There are three types of functions in Python: built-in functions, anonymous lambda functions, and user-defined functions. Functions help organize code by breaking programs into smaller, modular chunks. They reduce code duplication, decompose complex problems, improve clarity, and allow code reuse. Functions can take arguments and return values. Built-in functions are pre-defined to perform operations and return results when given the required arguments.
This document summarizes different types of operators in Java including assignment, increment/decrement, arithmetic, bitwise, relational, logical, ternary, shift, and instance of operators. It provides examples of each type of operator and describes what they are used for such as assigning values, performing mathematical operations, comparing values, and checking object types. The key types of operators covered are assignment, arithmetic, relational, logical, and instance of operators.
This document discusses operators in Java, including assignment, arithmetic, relational, and logical operators. It provides examples of using various operators and discusses some key points about operator precedence and equality testing. Specifically, it covers compound assignment operators, relational operators for comparison, and how equality is determined for primitives and object references. It also notes some topics about operators that are no longer covered on the Java certification exam.
Operators in Java include assignment, arithmetic, relational, logical, and other specialized operators. Assignment operators assign values to variables, arithmetic operators perform math operations, relational operators compare values, and logical operators combine conditional statements. There are unary, binary, and ternary operators that take one, two, or three operands respectively. Common operators include +, -, *, /, %, ++, --, =, ==, !=, <, >, <=, >=, &&, ||, and instanceof.
Lambda expressions, default methods in interfaces, and the new date/time API are among the major new features in Java 8. Lambda expressions allow for functional-style programming by treating functionality as a method argument or anonymous implementation. Default methods add new capabilities to interfaces while maintaining backwards compatibility. The date/time API improves on the old Calendar and Date APIs by providing immutable and easier to use classes like LocalDate.
Java 8 introduced several new features including default and static methods in interfaces, lambda expressions, the Optional class, streams, method references, a new date/time API, the Nashorn JavaScript engine, and parallel arrays. Some of the key features are default methods that allow interfaces to provide default implementations, lambda expressions that allow passing code as data, and streams that enable functional-style programming for collections.
Refactor your code to fix code smells, with the right methods from the Gurus. Watch Martin Fowler talk about TDD and Red-Green Refactoring, and follow the catalog as advised
This document discusses functional programming concepts in Ruby. It defines functional programming as treating computation as the evaluation of functions without state or mutable data. This is compared to imperative programming which describes computation through statements that change program state. Pure functions are described as always returning the same result given the same arguments without side effects. Functional programming benefits include reliability, parallelism, and ease of testing and debugging, while disadvantages include perceived complexity and difficulties with IO and state.
This chapter discusses:
1. Program flow control and statements like conditionals and loops that alter normal linear execution.
2. Conditional statements like if/else that allow choosing which statement executes based on a boolean condition.
3. Repetition statements like while and for loops that repeatedly execute a statement as long as/for as long as a condition is true.
The document is a presentation on lambda expressions in Java 8 given by Isaac Carter. It introduces lambda expressions and functional programming concepts in Java 8 such as functional interfaces, streams, and method references. It provides examples of using lambda expressions with common Java 8 APIs like forEach(), Predicate, and stream(). The presentation emphasizes thinking declaratively rather than imperatively in Java 8 and leveraging lambda expressions to let Java do more of the work.
This document introduces lambda expressions in Java 8. It provides background on why lambda expressions were added to Java, including to allow for more functional programming and parallel processing. It covers the syntax of lambda expressions, when they should and should not be used, functional interfaces, method and constructor references, referencing external variables, debugging lambda expressions, and new lambda methods added in Java 8. The document also advertises exercises for the reader to complete to practice using lambda expressions.
1) Java 8 introduced many new features to support functional programming in Java, such as lambda expressions, default methods in interfaces, and streams.
2) Lambda expressions allow implementing functional interfaces with anonymous methods, avoiding the need to create anonymous inner classes.
3) Default methods allow adding new methods to interfaces without breaking existing implementations, and streams allow performing bulk operations on collections in a declarative way.
Java provides a rich set of operators that are divided into arithmetic, relational, bitwise, logical, and assignment operators. These operators allow mathematical and logical manipulation of variables and values in Java programs. The document then proceeds to describe each type of operator in detail providing examples of their usage.
This document summarizes operators and expressions in Java. It discusses the four main categories of operators: arithmetic, bitwise, relational, and logical. For each category, it provides examples of the different operators and how they work. The key points covered include:
- Arithmetic operators like +, -, *, /, % that perform math operations.
- Bitwise operators like &, |, ^ that operate on individual bits.
- Relational operators like ==, !=, <, > that compare values and return a boolean.
- Logical operators like &&, ||, ! that combine boolean expressions.
- Assignment operators like = that store values in variables.
- Special operators
This document provides an agenda for a Java 8 training session that covers Lambdas and functional interfaces, the Stream API, default and static methods in interfaces, Optional, the new Date/Time API, and Nashorn JavaScript engine. It includes sections on Lambda expressions and method references syntax, functional interfaces, built-in functional interfaces, streams versus collections, using Optional to avoid null checks, extending interfaces with default methods, and key concepts of the new Date/Time and Nashorn JavaScript APIs.
Scala is a hybrid language that blends object-oriented and functional programming. It is statically typed and runs on the JVM. Scala has classes, objects, traits, and supports immutability, concurrency with actors, and pattern matching. Functions are first-class citizens and can be passed as parameters or returned from methods.
This document discusses algebraic specification, which specifies an object class or type in terms of the relationships between its defined operations. An algebraic specification defines a system as a heterogeneous algebra consisting of different sets with defined operations. It describes the types, syntax, equations, and properties of algebraic specifications. Advantages are that they are unambiguous, precise, and allow studying the effects of operations, while disadvantages are that ensuring completeness is difficult.
In this lesson, we will start by defining the basic concept related to Pyhton: operations, variables, and basic types.
Then we will define the concept of a function, and how to use it.
[Notebook link]( https://drive.google.com/file/d/1T4T32lyCkT4J992tfnKUADQU88Qvlrvc/view?usp=drivesdk)
Finally, we will explain the concept of modules and libraries. And, we will show how to install these libraries in Google Colab.
The document discusses various operators in Java including mathematical, assignment, increment/decrement, relational, logical, ternary, string and casting operators. It provides examples of using each operator and notes precedence rules and other behaviors like type promotion and truncation versus rounding during casting.
Functions are blocks of reusable code that perform specific tasks. There are three types of functions in Python: built-in functions, anonymous lambda functions, and user-defined functions. Functions help organize code by breaking programs into smaller, modular chunks. They reduce code duplication, decompose complex problems, improve clarity, and allow code reuse. Functions can take arguments and return values. Built-in functions are pre-defined to perform operations and return results when given the required arguments.
This document summarizes different types of operators in Java including assignment, increment/decrement, arithmetic, bitwise, relational, logical, ternary, shift, and instance of operators. It provides examples of each type of operator and describes what they are used for such as assigning values, performing mathematical operations, comparing values, and checking object types. The key types of operators covered are assignment, arithmetic, relational, logical, and instance of operators.
This document discusses operators in Java, including assignment, arithmetic, relational, and logical operators. It provides examples of using various operators and discusses some key points about operator precedence and equality testing. Specifically, it covers compound assignment operators, relational operators for comparison, and how equality is determined for primitives and object references. It also notes some topics about operators that are no longer covered on the Java certification exam.
Operators in Java include assignment, arithmetic, relational, logical, and other specialized operators. Assignment operators assign values to variables, arithmetic operators perform math operations, relational operators compare values, and logical operators combine conditional statements. There are unary, binary, and ternary operators that take one, two, or three operands respectively. Common operators include +, -, *, /, %, ++, --, =, ==, !=, <, >, <=, >=, &&, ||, and instanceof.
Lambda expressions, default methods in interfaces, and the new date/time API are among the major new features in Java 8. Lambda expressions allow for functional-style programming by treating functionality as a method argument or anonymous implementation. Default methods add new capabilities to interfaces while maintaining backwards compatibility. The date/time API improves on the old Calendar and Date APIs by providing immutable and easier to use classes like LocalDate.
Java 8 introduced several new features including default and static methods in interfaces, lambda expressions, the Optional class, streams, method references, a new date/time API, the Nashorn JavaScript engine, and parallel arrays. Some of the key features are default methods that allow interfaces to provide default implementations, lambda expressions that allow passing code as data, and streams that enable functional-style programming for collections.
Refactor your code to fix code smells, with the right methods from the Gurus. Watch Martin Fowler talk about TDD and Red-Green Refactoring, and follow the catalog as advised
This document discusses functional programming concepts in Ruby. It defines functional programming as treating computation as the evaluation of functions without state or mutable data. This is compared to imperative programming which describes computation through statements that change program state. Pure functions are described as always returning the same result given the same arguments without side effects. Functional programming benefits include reliability, parallelism, and ease of testing and debugging, while disadvantages include perceived complexity and difficulties with IO and state.
This chapter discusses:
1. Program flow control and statements like conditionals and loops that alter normal linear execution.
2. Conditional statements like if/else that allow choosing which statement executes based on a boolean condition.
3. Repetition statements like while and for loops that repeatedly execute a statement as long as/for as long as a condition is true.
The document is a presentation on lambda expressions in Java 8 given by Isaac Carter. It introduces lambda expressions and functional programming concepts in Java 8 such as functional interfaces, streams, and method references. It provides examples of using lambda expressions with common Java 8 APIs like forEach(), Predicate, and stream(). The presentation emphasizes thinking declaratively rather than imperatively in Java 8 and leveraging lambda expressions to let Java do more of the work.
This document introduces lambda expressions in Java 8. It provides background on why lambda expressions were added to Java, including to allow for more functional programming and parallel processing. It covers the syntax of lambda expressions, when they should and should not be used, functional interfaces, method and constructor references, referencing external variables, debugging lambda expressions, and new lambda methods added in Java 8. The document also advertises exercises for the reader to complete to practice using lambda expressions.
1) Java 8 introduced many new features to support functional programming in Java, such as lambda expressions, default methods in interfaces, and streams.
2) Lambda expressions allow implementing functional interfaces with anonymous methods, avoiding the need to create anonymous inner classes.
3) Default methods allow adding new methods to interfaces without breaking existing implementations, and streams allow performing bulk operations on collections in a declarative way.
Java 8 introduced several new features including lambda expressions, default methods in interfaces, streams API and others. Lambda expressions allow implementing functional interfaces using anonymous functions. Interfaces can now define default and static methods. The streams API allows performing bulk operations on collections in a declarative way. Some performance improvements in Java 8 include faster common data structures like HashMap, garbage collector improvements and enhanced fork/join framework.
Cover Basic concept for Functional Programming in Java. Define new functional interfaces, lambda expressions, how to translate lambda expression, JVM deal with new byte code etc. This is not the perfect slides for functional programming, but trying cover simple basic functional programming.
The document provides an introduction to Java 8 streams. It discusses intermediate and terminal stream operations such as filter(), sorted(), forEach(), and reduce(). It describes reductions like max(), min(), sum(), count(), and average(). It covers find methods, match methods, and Optional. It also discusses limiting, skipping, and distinct elements in streams.
This document provides an overview and agenda for an introduction to functional programming in Java. It discusses key functional programming concepts like lambda expressions, functional interfaces, and method references. It also provides examples of lambda expressions, method references, and how to use Streams API to filter, map and reduce Collections in a functional style. The document introduces Java 8 features that enable functional programming in Java and provides examples of how to write functional code.
Introduction to functional programming with java 8JavaBrahman
Recently gave a presentation in a Java Meetup in Bangalore on basics of functional programming, new functional features in Java 8, and introduction to the basic concepts of functional interfaces and lambda expressions...
This document provides an outline and overview of new features in Java 8. It discusses behavior parameterization through lambda expressions and method references, which allow passing behaviors as arguments in place of anonymous classes. It also covers the Stream API for functional-style processing of collections, Optional as an alternative to null, default methods to allow interfaces to evolve, and CompletableFuture for composable asynchronous programming. Finally, it notes some potential downsides of Java 8 like longer debugging with lambdas and limitations of its functional support.
In this Meetup Victor Perepelitsky - R&D Technical Leader at LivePerson leading the 'Real Time Event Processing Platform' team , will talk about Java 8', 'Stream API', 'Lambda', and 'Method reference'.
Victor will clarify what functional programming is and how can you use java 8 in order to create better software.
Victor will also cover some pain points that Java 8 did not solve regarding functionality and see how you can work around it.
In Java 8, the java.util.function has numerous built-in interfaces. Other packages in the Java library (notably java.util.stream package) make use of the interfaces defined in this package. Java 8 developers should be familiar with using key interfaces provided in this package. This presentation provides an overview of four key functional interfaces (Consumer, Supplier, Function, and Predicate) provided in this package.
In this Meetup Victor Perepelitsky - R&D Technical Leader at LivePerson leading the 'Real Time Event Processing Platform' team , talked about Java 8', 'Stream API', 'Lambda', and 'Method reference'.
Clarified what functional programming is and how can you use java 8 in order to create better software.
Victor will also covered some pain points that java 8 did not solve regarding functional and see how you can workaround it.
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.
This document provides an overview of new features being introduced in Java 8, with a focus on lambda expressions, default methods, and bulk data operations. It discusses the syntax and usage of lambda expressions, how they are represented at runtime using functional interfaces, and how variable capturing works. New functional interfaces being added to Java 8 are presented, including examples like Consumer and Function. The document also explores how lambda expressions are compiled, showing how invokedynamic bytecode instructions are used to dispatch lambda calls at runtime. In summary, the document serves as an introduction to key new language features in Java 8 that improve support for functional programming and parallel operations.
Do you want to learn functional programming in Java using lambda expressions introduced in Java 8? Do you want to explore the foundational concepts to explore powerful stream API? This presentation provides an overview of lambda functions introduced in Java 8 through examples. Topics covered: What is functional programming, creating lambda expressions, functional interfaces, built-in functional interfaces, and method references.
Make sure you have JDK 8 installed for trying out the programs as you go through the self-contained programming examples.
Lambda expressions allow implementing anonymous functions more concisely. Interfaces can now contain default and static methods. Streams facilitate functional-style operations on collections of elements. Optional handles null references more gracefully. The Date/Time API replaces the previous Date and Calendar classes. Nashorn allows executing JavaScript code from Java. Various new tools like jdeps were introduced.
Rearchitecturing a 9-year-old legacy Laravel application.pdfTakumi Amitani
An initiative to re-architect a Laravel legacy application that had been running for 9 years using the following approaches, with the goal of improving the system’s modifiability:
・Event Storming
・Use Case Driven Object Modeling
・Domain Driven Design
・Modular Monolith
・Clean Architecture
This slide was used in PHPxTKY June 2025.
https://phpxtky.connpass.com/event/352685/
May 2025: Top 10 Read Articles Advanced Information Technologyijait
International journal of advanced Information technology (IJAIT) is a bi monthly open access peer-reviewed journal, will act as a major forum for the presentation of innovative ideas, approaches, developments, and research projects in the area advanced information technology applications and services. It will also serve to facilitate the exchange of information between researchers and industry professionals to discuss the latest issues and advancement in the area of advanced IT. Core areas of advanced IT and multi-disciplinary and its applications will be covered during the conferences.
Rigor, ethics, wellbeing and resilience in the ICT doctoral journeyYannis
The doctoral thesis trajectory has been often characterized as a “long and windy road” or a journey to “Ithaka”, suggesting the promises and challenges of this journey of initiation to research. The doctoral candidates need to complete such journey (i) preserving and even enhancing their wellbeing, (ii) overcoming the many challenges through resilience, while keeping (iii) high standards of ethics and (iv) scientific rigor. This talk will provide a personal account of lessons learnt and recommendations from a senior researcher over his 30+ years of doctoral supervision and care for doctoral students. Specific attention will be paid on the special features of the (i) interdisciplinary doctoral research that involves Information and Communications Technologies (ICT) and other scientific traditions, and (ii) the challenges faced in the complex technological and research landscape dominated by Artificial Intelligence.
First Review PPT gfinal gyft ftu liu yrfut goSowndarya6
CyberShieldX provides end-to-end security solutions, including vulnerability assessment, penetration testing, and real-time threat detection for business websites. It ensures that organizations can identify and mitigate security risks before exploitation.
Unlike traditional security tools, CyberShieldX integrates AI models to automate vulnerability detection, minimize false positives, and enhance threat intelligence. This reduces manual effort and improves security accuracy.
Many small and medium businesses lack dedicated cybersecurity teams. CyberShieldX provides an easy-to-use platform with AI-powered insights to assist non-experts in securing their websites.
Traditional enterprise security solutions are often expensive. CyberShieldX, as a SaaS platform, offers cost-effective security solutions with flexible pricing for businesses of all sizes.
Businesses must comply with security regulations, and failure to do so can result in fines or data breaches. CyberShieldX helps organizations meet compliance requirements efficiently.
A DECISION SUPPORT SYSTEM FOR ESTIMATING COST OF SOFTWARE PROJECTS USING A HY...ijfcstjournal
One of the major challenges for software, nowadays, is software cost estimation. It refers to estimating the
cost of all activities including software development, design, supervision, maintenance and so on. Accurate
cost-estimation of software projects optimizes the internal and external processes, staff works, efforts and
the overheads to be coordinated with one another. In the management software projects, estimation must
be taken into account so that reduces costs, timing and possible risks to avoid project failure. In this paper,
a decision- support system using a combination of multi-layer artificial neural network and decision tree is
proposed to estimate the cost of software projects. In the model included into the proposed system,
normalizing factors, which is vital in evaluating efforts and costs estimation, is carried out using C4.5
decision tree. Moreover, testing and training factors are done by multi-layer artificial neural network and
the most optimal values are allocated to them. The experimental results and evaluations on Dataset
NASA60 show that the proposed system has less amount of the total average relative error compared with
COCOMO model.
11th International Conference on Data Mining (DaMi 2025)kjim477n
Welcome To DAMI 2025
Submit Your Research Articles...!!!
11th International Conference on Data Mining (DaMi 2025)
July 26 ~ 27, 2025, London, United Kingdom
Submission Deadline : June 07, 2025
Paper Submission : https://csit2025.org/submission/index.php
Contact Us : Here's where you can reach us : [email protected] or [email protected]
For more details visit : Webpage : https://csit2025.org/dami/index
How Binning Affects LED Performance & Consistency.pdfMina Anis
🔍 What’s Inside:
📦 What Is LED Binning?
• The process of sorting LEDs by color temperature, brightness, voltage, and CRI
• Ensures visual and performance consistency across large installations
🎨 Why It Matters:
• Inconsistent binning leads to uneven color and brightness
• Impacts brand perception, customer satisfaction, and warranty claims
📊 Key Concepts Explained:
• SDCM (Standard Deviation of Color Matching)
• Recommended bin tolerances by application (e.g., 1–3 SDCM for retail/museums)
• How to read bin codes from LED datasheets
• The difference between ANSI/NEMA standards and proprietary bin maps
🧠 Advanced Practices:
• AI-assisted bin prediction
• Color blending and dynamic calibration
• Customized binning for high-end or global projects
3. Writing Simple Lambdas
—> A lambda expression is a block of code that gets passed
around. A lambda expression can be thought as a continued
anonymous method. A lambda expression has parameters and a
body just like regular methods do, but it doesn’t have a name like
a real method.
5. Which Variables Can My
Lambda Access?
• Lambdas are allowed to access instance and static variables.
• Method parameters and local variables could be used if they
are not assigned new values. Finals and effectively final
variables.
6. Functional Interface
• A Functional Interface
has exactly one
abstract method.
• It could have any
numbers of default
methods.
7. Built-In Functional Interfaces
• Java 8 provides built-in functional interfaces in java.util.function
package.
Interface Parameters Return Type Method
Supplier<T> 0 T get
Consumer<T> 1(T) void accept
BiConsumer<T,U> 2(T,U) void accept
Predicate<T> 1(T) boolean test
BiPredicate<T> 2(T,U) boolean test
UnaryOperator<T> 1(T) T apply
BinaryOperator<T,T> 2(T,T) T apply
Function<T,R> 1(T) R apply
BiFunction<T,U,R> 2(T,U) R apply
8. Implementing Supplier
• Supplier interfaced is used when you want to
generate or supply values without taking
parameters.
• Related method name is get().
9. Implementing Consumers
• Consumer interfaces used when you want to do
something with parameter but not return
anything.
• Related method name is accept().
10. Implementing Predicates
• Predicates are often used for distinguishing
elements.
• Related method name is test(). And() and Negate()
are useful default methods.
14. Optionals
• An optional could have a value inside or not.
• Optional.empty() Optional.of()
100.0
15. Optional Methods
Method Optional Empty
Optional with
Value
get() Throws an Exception Returns value
ifPresent() Returns false Returns true
ifPresent(Consumer cons) Does nothing Calls consumer
orElse(T other)
Returns other
parameter
Returns value
orElseThrow(Supplier s)
Throws supplied
exception
Returns value
orElseGet(Supplier s)
Returns supplied
value
Returns value
16. Optional Methods
• Returning an optional instead of null is more clear
statement that tells there might be no value.
• Usage of sample methods on an empty optional
17. Thank You
References
OCA Oracle Certified Associate Java SE 8 Programmer I Study Guide
OCP Oracle Certified Professional Java SE 8 Programmer II Study Guide
You may reach piece of codes in the slides on Github page
https://github.com/AngelThread/Java8/tree/master/Functional_Programming_in_Java_8
Ugur Yeter
[email protected]
*Please do not hesitate to contact me if you have any questions related to slides