SlideShare ist ein Scribd-Unternehmen logo
1 von 15
Java 8: what’s new
and what’s hot
By Sergii Maliarov
Current status
- Java 8 was released on 18 March 2014
- From October 2014 (Java SE 8 Update 25),
Java 8 has been the default version to
download on java.com
- Oracle will no longer post updates of Java
SE 7 to its public download sites after April
2015
Language-level changes
- Lambda expressions
- Functional Interfaces
- References to constructors and methods
- Default and static methods in interfaces
- Repeating annotations, type annotations
- Method parameter reflection
Lambda expressions
Lambda expression is an anonymous function that can be
assigned to a variable (not always) and be executed by
calling that variable or directly. Lambda expressions have
access to final variables from the corresponding scope.
For example, you may create the following object:
Comparator<String> strLenComp = (firstStr, secondStr) ->
Integer.compare(firstStr.length(), secondStr.length());
And then you may sort your list using that object:
Collections.sort(myListOfStrings, strLenComp);
Functional interfaces
Functional interface is an interface with only
one abstract method.
If your interface is a functional interface then
you can create a lambda function of such type
and pass it whenever you need to. Like in the
previous example.
References to constructors and
methods
You may reference a method or a constructor as a lambda-expression
● object::instanceMethod
x::equals is in fact y -> x.equals(y)
● Class::staticMethod
System.out::println is in fact x -> System.out.println(x)
● Class::instanceMethod
String::compareToIgnoreCase is in fact (x, y) ->
x.compareToIgnoreCase(y)
● Class::new
MyClass::new is in fact x -> new MyClass(x)
Default and static methods in
interfaces
The interface may declare a default
implementation of a method.
public int compareTo(T other);
public default boolean gt(T other) {
return compareTo(other) > 0;
}
And finally you may have static methods in
interfaces.
Repeating annotations, type
annotations
● It’s now possible to repeat annotation several times:
@interface Hints {Hint[] value();}
@Repeatable(Hints.class)@interface Hint {String value();}
@Hint("hint1")@Hint("hint2") class MyClass {}
In the example above class MyClass now automatically has annotation Hints.
● Also now we have two more targets for an annotation:
@Target({ElementType.TYPE_PARAMETER, ElementType.TYPE_USE})
@interface NotNull{}
Examples:
List<@NotNull String> nonEmptyList;
String nonEmptyString = (@NotNull String) maybeEmpty;
Method parameter reflection
Now you can obtain the names of the formal
parameters of any method or constructor with
the method
java.lang.reflect.Executable.getPar
ameters if your code is compiled with -
parameters option to the javac compiler.
What else has changed
- Stream API
- New date/time API
- Project Nashorn - JavaScript on JVM
- Tens of other small and big changes and
additions
Stream API
java.util.Stream is a sequence of elements on which you may perform intermediate (result in that
stream) or terminal (result in something else) operations. Stream can be linear or parallel. The whole
conception of stream comes from Functional Programming.
Example:
List<String> stringCollection = new ArrayList<>();
// add elements to stringCollection
long startsWithB = stringCollection.parallelStream().filter((s) ->
s.startsWith("b")).count();
Maps do not support streams. But now they have some useful methods like putIfAbsent, merge,
getOrDefault.
New date/time API
- Inspired by Joda-Time with some important differences
- use class Clock instead of java.util.Date and
System.currentTimeMillis():
Clock clock = Clock.systemDefaultZone();
long millis = clock.millis();
Instant instant = clock.instant();// time in millis
- use ZoneId to work with time zones
- use LocalTime, LocalDate, LocalDateTime and few other new
classes for purposes that can be easily guessed from their names.
- use DateTimeFormatter for thread-safe date parsing and formatting
Project Nashorn
- Compiles JS to JVM bytecode
- JavaScript may now be embedded to a Java
programm
- also allows to develop free standing
JavaScript applications using the jrunscript
command-line tool
What else was added that can be
interesting?
- Statically-linked JNI libraries
- Removal of the permanent generation
- JavaFX improvements
- New standard classes and utils ike Arrays.parallelSort,
StampedLock, CompletableFuture
- See the full list of all the changes at
http://www.oracle.com/technetwork/java/javase/8-whats-new-2157071.html
What’s next
Java 9
- Somewhere in 2016
- Modularization of the JDK, several new APIs
(JSON, HTTP, Processes, etc), compiler and
JDK improvements
- See http://openjdk.java.net/projects/jdk9/ for
the full list of planned features

Weitere ähnliche Inhalte

Was ist angesagt?

Matlab Programming Tips Part 1
Matlab Programming Tips Part 1Matlab Programming Tips Part 1
Matlab Programming Tips Part 1Shameer Ahmed Koya
 
Java Tutorial Lab 5
Java Tutorial Lab 5Java Tutorial Lab 5
Java Tutorial Lab 5Berk Soysal
 
Functional Programming With Scala
Functional Programming With ScalaFunctional Programming With Scala
Functional Programming With ScalaKnoldus Inc.
 
C++ Templates_ Program to Swap Two Numbers Using Function Template - The Craz...
C++ Templates_ Program to Swap Two Numbers Using Function Template - The Craz...C++ Templates_ Program to Swap Two Numbers Using Function Template - The Craz...
C++ Templates_ Program to Swap Two Numbers Using Function Template - The Craz...Rishikesh Agrawani
 
Implicit conversion and parameters
Implicit conversion and parametersImplicit conversion and parameters
Implicit conversion and parametersKnoldus Inc.
 
Anonymous and Inline Functions in MATLAB
Anonymous and Inline Functions in MATLABAnonymous and Inline Functions in MATLAB
Anonymous and Inline Functions in MATLABShameer Ahmed Koya
 
The Functional Programming Triad of fold, scan and iterate
The Functional Programming Triad of fold, scan and iterateThe Functional Programming Triad of fold, scan and iterate
The Functional Programming Triad of fold, scan and iteratePhilip Schwarz
 
Operator overloading
Operator overloadingOperator overloading
Operator overloadingfarhan amjad
 

Was ist angesagt? (20)

Java 8
Java 8Java 8
Java 8
 
Matlab Programming Tips Part 1
Matlab Programming Tips Part 1Matlab Programming Tips Part 1
Matlab Programming Tips Part 1
 
Java 8 Lambda Expressions
Java 8 Lambda ExpressionsJava 8 Lambda Expressions
Java 8 Lambda Expressions
 
C# Method overloading
C# Method overloadingC# Method overloading
C# Method overloading
 
Java 8 lambda
Java 8 lambdaJava 8 lambda
Java 8 lambda
 
Java8 features
Java8 featuresJava8 features
Java8 features
 
Java Tutorial Lab 5
Java Tutorial Lab 5Java Tutorial Lab 5
Java Tutorial Lab 5
 
Java 8 Lambda Expressions
Java 8 Lambda ExpressionsJava 8 Lambda Expressions
Java 8 Lambda Expressions
 
Templates in c++
Templates in c++Templates in c++
Templates in c++
 
Java 8 Intro - Core Features
Java 8 Intro - Core FeaturesJava 8 Intro - Core Features
Java 8 Intro - Core Features
 
Java8
Java8Java8
Java8
 
Template C++ OOP
Template C++ OOPTemplate C++ OOP
Template C++ OOP
 
Templates
TemplatesTemplates
Templates
 
Functional Programming With Scala
Functional Programming With ScalaFunctional Programming With Scala
Functional Programming With Scala
 
C++ Templates_ Program to Swap Two Numbers Using Function Template - The Craz...
C++ Templates_ Program to Swap Two Numbers Using Function Template - The Craz...C++ Templates_ Program to Swap Two Numbers Using Function Template - The Craz...
C++ Templates_ Program to Swap Two Numbers Using Function Template - The Craz...
 
Implicit conversion and parameters
Implicit conversion and parametersImplicit conversion and parameters
Implicit conversion and parameters
 
Scala functions
Scala functionsScala functions
Scala functions
 
Anonymous and Inline Functions in MATLAB
Anonymous and Inline Functions in MATLABAnonymous and Inline Functions in MATLAB
Anonymous and Inline Functions in MATLAB
 
The Functional Programming Triad of fold, scan and iterate
The Functional Programming Triad of fold, scan and iterateThe Functional Programming Triad of fold, scan and iterate
The Functional Programming Triad of fold, scan and iterate
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 

Andere mochten auch

Lambda expressions java8 - yousry
Lambda expressions java8 - yousryLambda expressions java8 - yousry
Lambda expressions java8 - yousryyousry ibrahim
 
Exploring Streams and Lambdas in Java8
Exploring Streams and Lambdas in Java8Exploring Streams and Lambdas in Java8
Exploring Streams and Lambdas in Java8Isuru Samaraweera
 
Boost your craftsmanship with Java 8
Boost your craftsmanship with Java 8Boost your craftsmanship with Java 8
Boost your craftsmanship with Java 8João Nunes
 
Java8 Neue Sprachfeatures - Lambda/Streams/default Methods/FunctionalInterfaces
Java8 Neue Sprachfeatures - Lambda/Streams/default Methods/FunctionalInterfacesJava8 Neue Sprachfeatures - Lambda/Streams/default Methods/FunctionalInterfaces
Java8 Neue Sprachfeatures - Lambda/Streams/default Methods/FunctionalInterfacesDirk Detering
 
Why is Java relevant? New features of Java8
Why is Java relevant? New features of Java8 Why is Java relevant? New features of Java8
Why is Java relevant? New features of Java8 xshyamx
 
Scala is java8.next()
Scala is java8.next()Scala is java8.next()
Scala is java8.next()daewon jeong
 
Introduction to functional programming with java 8
Introduction to functional programming with java 8Introduction to functional programming with java 8
Introduction to functional programming with java 8JavaBrahman
 
JDays Lviv 2014: Java8 vs Scala: Difference points & innovation stream
JDays Lviv 2014:  Java8 vs Scala:  Difference points & innovation streamJDays Lviv 2014:  Java8 vs Scala:  Difference points & innovation stream
JDays Lviv 2014: Java8 vs Scala: Difference points & innovation streamRuslan Shevchenko
 
Java8 and Functional Programming
Java8 and Functional ProgrammingJava8 and Functional Programming
Java8 and Functional ProgrammingYiguang Hu
 
Functional Java 8 in everyday life
Functional Java 8 in everyday lifeFunctional Java 8 in everyday life
Functional Java 8 in everyday lifeAndrea Iacono
 
Java8 training - Class 1
Java8 training  - Class 1Java8 training  - Class 1
Java8 training - Class 1Marut Singh
 
Java8 training - class 2
Java8 training - class 2Java8 training - class 2
Java8 training - class 2Marut Singh
 
Java8 training - class 3
Java8 training - class 3Java8 training - class 3
Java8 training - class 3Marut Singh
 
New Features in JDK 8
New Features in JDK 8New Features in JDK 8
New Features in JDK 8Martin Toshev
 

Andere mochten auch (20)

Java8 Lambda and Streams
Java8 Lambda and StreamsJava8 Lambda and Streams
Java8 Lambda and Streams
 
Lambda expressions java8 - yousry
Lambda expressions java8 - yousryLambda expressions java8 - yousry
Lambda expressions java8 - yousry
 
Exploring Streams and Lambdas in Java8
Exploring Streams and Lambdas in Java8Exploring Streams and Lambdas in Java8
Exploring Streams and Lambdas in Java8
 
Boost your craftsmanship with Java 8
Boost your craftsmanship with Java 8Boost your craftsmanship with Java 8
Boost your craftsmanship with Java 8
 
Java8
Java8Java8
Java8
 
Java8 Neue Sprachfeatures - Lambda/Streams/default Methods/FunctionalInterfaces
Java8 Neue Sprachfeatures - Lambda/Streams/default Methods/FunctionalInterfacesJava8 Neue Sprachfeatures - Lambda/Streams/default Methods/FunctionalInterfaces
Java8 Neue Sprachfeatures - Lambda/Streams/default Methods/FunctionalInterfaces
 
Why is Java relevant? New features of Java8
Why is Java relevant? New features of Java8 Why is Java relevant? New features of Java8
Why is Java relevant? New features of Java8
 
Scala is java8.next()
Scala is java8.next()Scala is java8.next()
Scala is java8.next()
 
2014 java functional
2014 java functional2014 java functional
2014 java functional
 
Java8
Java8Java8
Java8
 
Introduction to functional programming with java 8
Introduction to functional programming with java 8Introduction to functional programming with java 8
Introduction to functional programming with java 8
 
JDays Lviv 2014: Java8 vs Scala: Difference points & innovation stream
JDays Lviv 2014:  Java8 vs Scala:  Difference points & innovation streamJDays Lviv 2014:  Java8 vs Scala:  Difference points & innovation stream
JDays Lviv 2014: Java8 vs Scala: Difference points & innovation stream
 
Java8 and Functional Programming
Java8 and Functional ProgrammingJava8 and Functional Programming
Java8 and Functional Programming
 
Functional Java 8 in everyday life
Functional Java 8 in everyday lifeFunctional Java 8 in everyday life
Functional Java 8 in everyday life
 
Java8 training - Class 1
Java8 training  - Class 1Java8 training  - Class 1
Java8 training - Class 1
 
Java8 training - class 2
Java8 training - class 2Java8 training - class 2
Java8 training - class 2
 
Java8 training - class 3
Java8 training - class 3Java8 training - class 3
Java8 training - class 3
 
Java8 - Under the hood
Java8 - Under the hoodJava8 - Under the hood
Java8 - Under the hood
 
Java 8 Date-Time API
Java 8 Date-Time APIJava 8 Date-Time API
Java 8 Date-Time API
 
New Features in JDK 8
New Features in JDK 8New Features in JDK 8
New Features in JDK 8
 

Ähnlich wie Java8: what's new and what's hot

Ähnlich wie Java8: what's new and what's hot (20)

New features in jdk8 iti
New features in jdk8 itiNew features in jdk8 iti
New features in jdk8 iti
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentation
 
Major Java 8 features
Major Java 8 featuresMajor Java 8 features
Major Java 8 features
 
Introduction to new features in java 8
Introduction to new features in java 8Introduction to new features in java 8
Introduction to new features in java 8
 
Introduction to new features in java 8
Introduction to new features in java 8Introduction to new features in java 8
Introduction to new features in java 8
 
Xebicon2013 scala vsjava_final
Xebicon2013 scala vsjava_finalXebicon2013 scala vsjava_final
Xebicon2013 scala vsjava_final
 
Java 8 - An Overview
Java 8 - An OverviewJava 8 - An Overview
Java 8 - An Overview
 
Automatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to InterfacesAutomatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to Interfaces
 
java150929145120-lva1-app6892 (2).pptx
java150929145120-lva1-app6892 (2).pptxjava150929145120-lva1-app6892 (2).pptx
java150929145120-lva1-app6892 (2).pptx
 
Colloquium Report
Colloquium ReportColloquium Report
Colloquium Report
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
What's new in java 8
What's new in java 8What's new in java 8
What's new in java 8
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
 
Java 8 Workshop
Java 8 WorkshopJava 8 Workshop
Java 8 Workshop
 
Chap-2 Classes & Methods.pptx
Chap-2 Classes & Methods.pptxChap-2 Classes & Methods.pptx
Chap-2 Classes & Methods.pptx
 
Charles Sharp: Java 8 Streams
Charles Sharp: Java 8 StreamsCharles Sharp: Java 8 Streams
Charles Sharp: Java 8 Streams
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014
 

Kürzlich hochgeladen

%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...masabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxAnnaArtyushina1
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 

Kürzlich hochgeladen (20)

%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 

Java8: what's new and what's hot

  • 1. Java 8: what’s new and what’s hot By Sergii Maliarov
  • 2. Current status - Java 8 was released on 18 March 2014 - From October 2014 (Java SE 8 Update 25), Java 8 has been the default version to download on java.com - Oracle will no longer post updates of Java SE 7 to its public download sites after April 2015
  • 3. Language-level changes - Lambda expressions - Functional Interfaces - References to constructors and methods - Default and static methods in interfaces - Repeating annotations, type annotations - Method parameter reflection
  • 4. Lambda expressions Lambda expression is an anonymous function that can be assigned to a variable (not always) and be executed by calling that variable or directly. Lambda expressions have access to final variables from the corresponding scope. For example, you may create the following object: Comparator<String> strLenComp = (firstStr, secondStr) -> Integer.compare(firstStr.length(), secondStr.length()); And then you may sort your list using that object: Collections.sort(myListOfStrings, strLenComp);
  • 5. Functional interfaces Functional interface is an interface with only one abstract method. If your interface is a functional interface then you can create a lambda function of such type and pass it whenever you need to. Like in the previous example.
  • 6. References to constructors and methods You may reference a method or a constructor as a lambda-expression ● object::instanceMethod x::equals is in fact y -> x.equals(y) ● Class::staticMethod System.out::println is in fact x -> System.out.println(x) ● Class::instanceMethod String::compareToIgnoreCase is in fact (x, y) -> x.compareToIgnoreCase(y) ● Class::new MyClass::new is in fact x -> new MyClass(x)
  • 7. Default and static methods in interfaces The interface may declare a default implementation of a method. public int compareTo(T other); public default boolean gt(T other) { return compareTo(other) > 0; } And finally you may have static methods in interfaces.
  • 8. Repeating annotations, type annotations ● It’s now possible to repeat annotation several times: @interface Hints {Hint[] value();} @Repeatable(Hints.class)@interface Hint {String value();} @Hint("hint1")@Hint("hint2") class MyClass {} In the example above class MyClass now automatically has annotation Hints. ● Also now we have two more targets for an annotation: @Target({ElementType.TYPE_PARAMETER, ElementType.TYPE_USE}) @interface NotNull{} Examples: List<@NotNull String> nonEmptyList; String nonEmptyString = (@NotNull String) maybeEmpty;
  • 9. Method parameter reflection Now you can obtain the names of the formal parameters of any method or constructor with the method java.lang.reflect.Executable.getPar ameters if your code is compiled with - parameters option to the javac compiler.
  • 10. What else has changed - Stream API - New date/time API - Project Nashorn - JavaScript on JVM - Tens of other small and big changes and additions
  • 11. Stream API java.util.Stream is a sequence of elements on which you may perform intermediate (result in that stream) or terminal (result in something else) operations. Stream can be linear or parallel. The whole conception of stream comes from Functional Programming. Example: List<String> stringCollection = new ArrayList<>(); // add elements to stringCollection long startsWithB = stringCollection.parallelStream().filter((s) -> s.startsWith("b")).count(); Maps do not support streams. But now they have some useful methods like putIfAbsent, merge, getOrDefault.
  • 12. New date/time API - Inspired by Joda-Time with some important differences - use class Clock instead of java.util.Date and System.currentTimeMillis(): Clock clock = Clock.systemDefaultZone(); long millis = clock.millis(); Instant instant = clock.instant();// time in millis - use ZoneId to work with time zones - use LocalTime, LocalDate, LocalDateTime and few other new classes for purposes that can be easily guessed from their names. - use DateTimeFormatter for thread-safe date parsing and formatting
  • 13. Project Nashorn - Compiles JS to JVM bytecode - JavaScript may now be embedded to a Java programm - also allows to develop free standing JavaScript applications using the jrunscript command-line tool
  • 14. What else was added that can be interesting? - Statically-linked JNI libraries - Removal of the permanent generation - JavaFX improvements - New standard classes and utils ike Arrays.parallelSort, StampedLock, CompletableFuture - See the full list of all the changes at http://www.oracle.com/technetwork/java/javase/8-whats-new-2157071.html
  • 15. What’s next Java 9 - Somewhere in 2016 - Modularization of the JDK, several new APIs (JSON, HTTP, Processes, etc), compiler and JDK improvements - See http://openjdk.java.net/projects/jdk9/ for the full list of planned features