-
Notifications
You must be signed in to change notification settings - Fork 0
amitvermaatpl/java-8-features
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
### JAVA Code Review: Best Practices ### https://www.java-success.com/30-java-code-review-checklist-items/ ### JAVA Design Principles ### https://stackify.com/solid-design-principles/ ###==### JAVA_8 Features: Java 8 In Action ###==### Why Lambda? Functional Programming What is Lambda? Fuctional vs Object Oriented > A function that doesn’t have a name and doesn’t belong to any class. //Syntax of lambda expression (parameter_list) -> {function_body} A lambda expression in Java has these main parts: Lambda expression only has body and parameter list. 1. No name – function is anonymous so we don’t care about the name 2. Parameter list 3. Body – This is the main part of the function. 4. No return type – The java 8 compiler is able to infer the return type by checking the code. Why Functional Programming? "Passing Behavior: Behavior Parameterization" [Previous: Behavior is associated with an Object/Class.] Example: Greeting Behavior: public void greet(.....Behavior.....) // Pass the interface Greeting: perform() > HindiGreeting, EnglishGreeting etc. // JAVA 7 way: Polymorphism in Action // > Here we are a passing a thing that have the behavior, not the behavior //***// How Lambda? "Functions in Isolation" and Treated as values. [Function as a Value] ablockOfCode= public void perform(){Syso("Hello World");} = () -> {Syso("Hello World");} > greet( () -> Syso("Hindi Greeting") ) // JAVA 8 : Passing behavior directly // ===== CONCEPTS ====== greetingFunction= () -> Syso("Hindi Greeting"); addFunction= (int a, int b) -> a+b; 1. Type of Lambda expression? == "Functional Interface" 2. Lambda vs Interface Implemenation = 3. Lambda vs Anonymous Class = 4. Type Inference? StringLengthLambda lambda= (String s) -> { s.length(); } === s -> s.length(); // Type-I // 5. Exception Handling in lambda 6. Closures in lambda:= Comes in picture if we uses the scoped variable in Lambda-Expression, they freeze. 7. Method References:: Another way to use ############ Stream API Examples: http://www.java2novice.com/java-8/streams/ ############# CONCEPT: Collection of 6 Cars need some action:- Paint, fix the engine, fix the tires By using streams we can perform various aggregate operations on the data returned from collections, arrays, Input/Output operations. Create a stream() ---> Perform a intermediate operation[filter()] ----> then perform terminal operation [count()] # map() vs flatMap() # MAP: it applies a function on each element of stream and stores the value returned by the function into a new Stream. ##### OPTIONAL in java.util package ##### It is used to represent a value is present or absent. This class has various utility methods to facilitate code to handle values as ‘available’ or ‘not available’ instead of checking null values.
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published