SlideShare ist ein Scribd-Unternehmen logo
1 von 12
Colloquium Report
Faizan, Mohammad | MCA | May 4, 2015
JAVA 8
PAGE 1
Introduction
JAVA 8 (JDK 1.8) is a major release of JAVA programming language development.
Its initial version was released on 18 March 2014. With the Java 8 release, Java
provided support for functional programming, new JavaScript engine, new APIs for
date time manipulation, new streaming API, etc.
New Features
There are dozens of features added to Java 8, the most significant ones are mentioned below −
Lambda expression − Adds functional processing capability to Java.
Method references − Referencing functions by their names instead of invoking them directly.
Using functions as parameter.
Defaultmethod − Interface to have default method implementation.
New tools − New compiler tools and utilities are added.
Stream API − New stream API to facilitate pipeline processing.
Date Time API − Improved date time API.
Optional Class − Emphasis on best practices to handle null values properly.
The Biggest thing in java 8 is functional programming that means with java we can
not only object composition but we can also do functional composition.
We can achieve functional programming with java 8 with Lambda expression.
PAGE 2
Evolution
• The lambda calculus was introduced in the 1930s by Alonzo Church as
a mathematical system for defining computable functions.
• The lambda calculus is equivalent in definitional power to that of
Turing machines.
• The lambda calculus serves as the computational model underlying
functional programming languages such as Lisp, Haskell, and Ocaml
• Features from the lambda calculus such as lambda expressions have
been incorporated into many widely used programming languages
like C++ and now very recently Java 8.
What is Lambda Calculus
The central concept in the lambda calculus is an expression generated by
the following grammar which can denote a function definition, function
application, variable, or parenthesized expression:
expr → λ var . expr | expr expr | var | (expr)
We can think of a lambda-calculus expression as a program which when
evaluated by beta-reductions returns a result consisting of another lambda-
calculus expression.
Functional Programming
A style of programming that treats computation as the evaluation of
mathematical functions
 Eliminates side effects
 Treats data as being immutable
 Expressions have referential transparency
 Functions can take functions as arguments and return functions as results
 Prefers recursion over explicit for-loops
PAGE 3
Methods with Case study
1. Java 8 is the biggest change to Java since the inception of the language
2. Lambdas are the most important new addition
3. Java is playing catch-up: most major programming languages already have
support for lambda expressions
4. A big challenge was to introduce lambdas without requiring recompilation
of existing binaries
Lambda and Functional Interface
Lambdas (also known as closures) are the biggest and most awaited
language change in the whole Java 8 release. They allow us to treat
functionality as a method argument (passing functions around), or treat a
code as data: the concepts every functional developer is very familiar with.
Many languages on JVM platform (Groovy, Scala, …) have had lambdas
since day one, but Java developers had no choice but hammer the lambdas
with boilerplate anonymous classes.
Lambdas design discussions have taken a lot of time and community
efforts. But finally, the trade-offs have been found, leading to new concise
and compact language constructs. In its simplest form, a lambda could be
represented as a comma-separated list of parameters, the –> symbol and the
body. For example:
1 Arrays.asList( "a", "b", "d" ).forEach( e -> System.out.println( e ) );
PAGE 4
Default and Static Method
Java 8 extends interface declarations with two new concepts: default and
static methods. Default methods make interfaces somewhat similar to traits but
serve a bit different goal. They allow adding new methods to existing interfaces
without breaking the binary compatibility with the code written for older versions
of those interfaces.
The difference between default methods and abstract methods is that abstract
methods are required to be implemented. But default methods are not. Instead,
each interface must provide so called default implementation and all the
implementers will inherit it by default (with a possibility to override this default
implementation if needed). Let us take a look on example below.
private interface Defaulable {
// Interfaces now allow default methods, the implementer may or
// may not implement (override) them.
default String notRequired () {
return "Default implementation";
}
}
private static class DefaultableImpl implements Defaulable {
}
private static class OverridableImpl implements Defaulable{
@Override
public String notRequired() {
return "Overridden implementation";
}
}
PAGE 5
Method References
Method references provide the useful syntax to refer directly to exiting
methods or constructors of Java classes or objects (instances). With conjunction
of Lambdas expressions, method references make the language constructs look
compact and concise, leaving off boilerplate.
Below, considering the class Car as an example of different method definitions, let us distinguish
four supported types of method references.
public class FunctionalStyle {
public static void main (String [] args) {
List<Integer> values = Arrays.asList(1, 2, 3, 4, 5, 6);
System.out.println(" With for iterator");
int total = 0;
for (int e: values) {
total += e*2;
}
System.out.println(total);
values. stream ()
. map(e->e*2)
. reduce (0, (c,e)->c+e).forEach(System.out::print);
}
}
PAGE 6
Repeatingannotations
Since Java 5 introduced the annotations support, this feature became very
popular and is very widely used. However, one of the limitations of annotation
usage was the fact that the same annotation cannot be declared more than once at
the same location. Java 8 breaks this rule and introduced the repeating
annotations. It allows the same annotation to be repeated several times in place it
is declared.
@Color(name = "Red")
@Color(name = "Blue")
@Color(name = "Black")
public class Shirt {
public static void main(String[] args) {
Color[] colors =
Shirt.class.getAnnotationsByType(Color.class);
for (Color cl : colors )
System.out.println(cl.name());
}
}
Better Type Inference
Java 8 compiler has improved a lot on type inference. In many cases the
explicit type parameters could be inferred by compiler keeping the code cleaner.
Let us take a look on one of the examples.
public class Boundary {
public void hello(String name, int age) {
}
public static void main(String[] args) {
Method[] methods = Boundary.class.getMethods();
for (Method method : methods) {
System.out.print(method.getName() + "(");
Parameter[] parameters = method.getParameters();
for (Parameter parameter : parameters) {
PAGE 7
System.out.print(parameter.getType().getName() + " " + parameter.getName() + " ");
}
System.out.println(")");
}
}
}
Optional Class
The famous NullPointerException is by far the most popular cause
of Java application failures. Long time ago the great Google project introduced
the Optional as a solution to NullPointerExceptions, discouraging codebase
pollution with null checks and encouraging developers to write cleaner code.
Inspired by Google Guava, the Optional is now a part of Java 8 library.
Optional is just a container: it can hold a value of some type T or just be null. It
provides a lot of useful methods so the explicit null checks have no excuse
anymore. Please refer to official Java 8 documentation for more details.
We are going to take a look on two small examples of Optional usages: with
the null able value and with the value which does not allow nulls.
Streams
The newly added Stream API (java.util.stream) introduces real-world
functional-style programming into the Java. This is by far the most comprehensive
addition to Java library intended to make Java developers significantly more
productive by allowing them to write effective, clean, and concise code.
Stream API makes collections processing greatly simplified (but it is not limited to
Java collections only as we will see later). Let us take start off with simple class
called Task.
PAGE 8
public class ParallelStreams {
public static void main(String[] args) {
List<Integer> numbers = Arrays.asList(1,2,3,4,5,6,7,8,10);
System.out.println("With Stream");
numbers.stream()
.forEach(e -> System.out.print(e + " "));
System.out.println(" nWith parallelStream : 1");
numbers.parallelStream()
.forEach(e -> System.out.print(e + " "));
System.out.println("nWith parallelStream : 2");
numbers.parallelStream()
.forEach(e -> System.out.print(e + " "));
System.out.println("nWith parallelStream : 3");
numbers.parallelStream()
.forEach(e -> System.out.print(e + " "));
}
}
PAGE 9
Base64
Finally, the support of Base64 encoding has made its way into Java standard
library with Java 8 release. It is very easy to use as following example shows
off.
The particular set of 64 characters chosen to represent the 64 place-values for the
base varies between implementations. The general strategy is to choose 64
characters that are both members of a subset common to most encodings, and
also printable. This combination leaves the data unlikely to be modified in transit
through information systems, such as email, that were traditionally not 8-bit clean
public class Base64s {
public static void main (String [] args) {
String text = "Base 64 Finally In Java";
String encode = Base64.getEncoder()
.encodeToString(text.getBytes(StandardCharsets.US_ASCII));
System.out.println(encode);
String decode = new String( Base64.getDecoder().decode(encode) ,
StandardCharsets.US_ASCII );
System.out.println(decode);
}
}
New Features in Java runtime (JVM)
The PermGen space is gone and has been replaced with Metaspace . The JVM
options -XX:PermSize and –XX:MaxPermSize have been replaced by -
XX:MetaSpaceSize and -XX:MaxMetaspaceSize respectively.
PAGE 10
Conclusion
The future is here: Java 8 moves this great platform forward by delivering
the features to make developers much more productive. It is too early to move the
production systems to Java 8 but in the next couples of months its adoption should
slowly start growing. Nevertheless, the time is right to start preparing your code
bases to be compatible with Java 8 and to be ready to turn the switch once Java 8
proves to be safe and stable enough.
As a confirmation of community Java 8 acceptance, recently Pivotal
Released Spring Framework 4.0.3 with production-ready Java 8 support.
Resources
Some additional resources which discuss in depth different aspects of Java 8
features:
 What’s New in JDK 8: http://www.oracle.com/technetwork/java/javase/8-whats-
new-2157071.html
 The Java Tutorials: http://docs.oracle.com/javase/tutorial/
 WildFly 8, JDK 8, NetBeans 8, Java EE
7: http://blog.arungupta.me/2014/03/wildfly8-jdk8-netbeans8-javaee7-excellent-
combo-enterprise-java/
 Java 8 Tutorial: http://winterbe.com/posts/2014/03/16/java-8-tutorial/
 JDK 8 Command-line Static Dependency
Checker: http://marxsoftware.blogspot.ca/2014/03/jdeps.html
 The Illuminating Javadoc of JDK
8: http://marxsoftware.blogspot.ca/2014/03/illuminating-javadoc-of-jdk-8.html
 The Dark Side of Java 8: http://blog.jooq.org/2014/04/04/java-8-friday-the-dark-
side-of-java-8/
PAGE 11
 Installing Java™ 8 Support in Eclipse Kepler
SR2: http://www.eclipse.org/downloads/java8/
 Java 8: http://www.baeldung.com/java8
 Oracle Natron. A Next-Generation JavaScript Engine for the
JVM: http://www.oracle.com/technetwork/articles/java/jf14-nashorn-
2126515.html

Weitere ähnliche Inhalte

Was ist angesagt?

Jdbc Complete Notes by Java Training Center (Som Sir)
Jdbc Complete Notes by Java Training Center (Som Sir)Jdbc Complete Notes by Java Training Center (Som Sir)
Jdbc Complete Notes by Java Training Center (Som Sir)Som Prakash Rai
 
Hibernate complete notes_by_sekhar_sir_javabynatara_j
Hibernate complete notes_by_sekhar_sir_javabynatara_jHibernate complete notes_by_sekhar_sir_javabynatara_j
Hibernate complete notes_by_sekhar_sir_javabynatara_jSatya Johnny
 
Project Jigsaw in JDK9
Project Jigsaw in JDK9Project Jigsaw in JDK9
Project Jigsaw in JDK9Simon Ritter
 
SAP ABAP Latest Interview Questions with Answers by Garuda Trainings
SAP ABAP Latest Interview Questions with Answers by Garuda TrainingsSAP ABAP Latest Interview Questions with Answers by Garuda Trainings
SAP ABAP Latest Interview Questions with Answers by Garuda TrainingsGaruda Trainings
 
Java interview questions
Java interview questionsJava interview questions
Java interview questionsSoba Arjun
 
Java 9 New Features
Java 9 New FeaturesJava 9 New Features
Java 9 New FeaturesAli BAKAN
 
Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1sotlsoc
 
SMI - Introduction to Java
SMI - Introduction to JavaSMI - Introduction to Java
SMI - Introduction to JavaSMIJava
 
Application package
Application packageApplication package
Application packageJAYAARC
 

Was ist angesagt? (20)

Jdbc Complete Notes by Java Training Center (Som Sir)
Jdbc Complete Notes by Java Training Center (Som Sir)Jdbc Complete Notes by Java Training Center (Som Sir)
Jdbc Complete Notes by Java Training Center (Som Sir)
 
Spring jdbc
Spring jdbcSpring jdbc
Spring jdbc
 
Hibernate complete notes_by_sekhar_sir_javabynatara_j
Hibernate complete notes_by_sekhar_sir_javabynatara_jHibernate complete notes_by_sekhar_sir_javabynatara_j
Hibernate complete notes_by_sekhar_sir_javabynatara_j
 
Struts notes
Struts notesStruts notes
Struts notes
 
Project Jigsaw in JDK9
Project Jigsaw in JDK9Project Jigsaw in JDK9
Project Jigsaw in JDK9
 
Spring notes
Spring notesSpring notes
Spring notes
 
Data Access with JDBC
Data Access with JDBCData Access with JDBC
Data Access with JDBC
 
Jdbc
JdbcJdbc
Jdbc
 
jdbc document
jdbc documentjdbc document
jdbc document
 
Jdbc 1
Jdbc 1Jdbc 1
Jdbc 1
 
Jdbc
JdbcJdbc
Jdbc
 
SAP ABAP Latest Interview Questions with Answers by Garuda Trainings
SAP ABAP Latest Interview Questions with Answers by Garuda TrainingsSAP ABAP Latest Interview Questions with Answers by Garuda Trainings
SAP ABAP Latest Interview Questions with Answers by Garuda Trainings
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
Java RMI
Java RMIJava RMI
Java RMI
 
Jsp and jstl
Jsp and jstlJsp and jstl
Jsp and jstl
 
Java 9 New Features
Java 9 New FeaturesJava 9 New Features
Java 9 New Features
 
Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1
 
SMI - Introduction to Java
SMI - Introduction to JavaSMI - Introduction to Java
SMI - Introduction to Java
 
Jdbc_ravi_2016
Jdbc_ravi_2016Jdbc_ravi_2016
Jdbc_ravi_2016
 
Application package
Application packageApplication package
Application package
 

Andere mochten auch

Unit3 Software engineering UPTU
Unit3 Software engineering UPTUUnit3 Software engineering UPTU
Unit3 Software engineering UPTUMohammad Faizan
 
Lazy vs. Eager Loading Strategies in JPA 2.1
Lazy vs. Eager Loading Strategies in JPA 2.1Lazy vs. Eager Loading Strategies in JPA 2.1
Lazy vs. Eager Loading Strategies in JPA 2.1Patrycja Wegrzynowicz
 
Secure Authentication and Session Management in Java EE
Secure Authentication and Session Management in Java EESecure Authentication and Session Management in Java EE
Secure Authentication and Session Management in Java EEPatrycja Wegrzynowicz
 
Spring Boot. Boot up your development
Spring Boot. Boot up your developmentSpring Boot. Boot up your development
Spring Boot. Boot up your developmentStrannik_2013
 
JDBC - JPA - Spring Data
JDBC - JPA - Spring DataJDBC - JPA - Spring Data
JDBC - JPA - Spring DataArturs Drozdovs
 
Spring.Boot up your development
Spring.Boot up your developmentSpring.Boot up your development
Spring.Boot up your developmentStrannik_2013
 
Amazon Webservices for Java Developers - UCI Webinar
Amazon Webservices for Java Developers - UCI WebinarAmazon Webservices for Java Developers - UCI Webinar
Amazon Webservices for Java Developers - UCI WebinarCraig Dickson
 
Junior,middle,senior?
Junior,middle,senior?Junior,middle,senior?
Junior,middle,senior?Strannik_2013
 
Java Persistence API (JPA) - A Brief Overview
Java Persistence API (JPA) - A Brief OverviewJava Persistence API (JPA) - A Brief Overview
Java Persistence API (JPA) - A Brief OverviewCraig Dickson
 

Andere mochten auch (20)

Colloquium Report
Colloquium ReportColloquium Report
Colloquium Report
 
Unit3 Software engineering UPTU
Unit3 Software engineering UPTUUnit3 Software engineering UPTU
Unit3 Software engineering UPTU
 
Thinking Beyond ORM in JPA
Thinking Beyond ORM in JPAThinking Beyond ORM in JPA
Thinking Beyond ORM in JPA
 
Hibernate using jpa
Hibernate using jpaHibernate using jpa
Hibernate using jpa
 
Lazy vs. Eager Loading Strategies in JPA 2.1
Lazy vs. Eager Loading Strategies in JPA 2.1Lazy vs. Eager Loading Strategies in JPA 2.1
Lazy vs. Eager Loading Strategies in JPA 2.1
 
Secure Authentication and Session Management in Java EE
Secure Authentication and Session Management in Java EESecure Authentication and Session Management in Java EE
Secure Authentication and Session Management in Java EE
 
Spring Boot. Boot up your development
Spring Boot. Boot up your developmentSpring Boot. Boot up your development
Spring Boot. Boot up your development
 
Java persistence api 2.1
Java persistence api 2.1Java persistence api 2.1
Java persistence api 2.1
 
JPA For Beginner's
JPA For Beginner'sJPA For Beginner's
JPA For Beginner's
 
Second Level Cache in JPA Explained
Second Level Cache in JPA ExplainedSecond Level Cache in JPA Explained
Second Level Cache in JPA Explained
 
JPA - Beyond copy-paste
JPA - Beyond copy-pasteJPA - Beyond copy-paste
JPA - Beyond copy-paste
 
JDBC - JPA - Spring Data
JDBC - JPA - Spring DataJDBC - JPA - Spring Data
JDBC - JPA - Spring Data
 
Spring.Boot up your development
Spring.Boot up your developmentSpring.Boot up your development
Spring.Boot up your development
 
Spring
SpringSpring
Spring
 
Spring data jpa
Spring data jpaSpring data jpa
Spring data jpa
 
Spring Data Jpa
Spring Data JpaSpring Data Jpa
Spring Data Jpa
 
Amazon Webservices for Java Developers - UCI Webinar
Amazon Webservices for Java Developers - UCI WebinarAmazon Webservices for Java Developers - UCI Webinar
Amazon Webservices for Java Developers - UCI Webinar
 
Junior,middle,senior?
Junior,middle,senior?Junior,middle,senior?
Junior,middle,senior?
 
Introduction to JPA Framework
Introduction to JPA FrameworkIntroduction to JPA Framework
Introduction to JPA Framework
 
Java Persistence API (JPA) - A Brief Overview
Java Persistence API (JPA) - A Brief OverviewJava Persistence API (JPA) - A Brief Overview
Java Persistence API (JPA) - A Brief Overview
 

Ähnlich wie Colloquium Report

Introduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and StreamsIntroduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and StreamsEmiel Paasschens
 
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 InterfacesRaffi Khatchadourian
 
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...Raffi Khatchadourian
 
New Features of JAVA SE8
New Features of JAVA SE8New Features of JAVA SE8
New Features of JAVA SE8Dinesh Pathak
 
Java 8 - An Overview
Java 8 - An OverviewJava 8 - An Overview
Java 8 - An OverviewIndrajit Das
 
Functional programming in java 8 by harmeet singh
Functional programming in java 8 by harmeet singhFunctional programming in java 8 by harmeet singh
Functional programming in java 8 by harmeet singhHarmeet Singh(Taara)
 
Java 8 New features
Java 8 New featuresJava 8 New features
Java 8 New featuresSon Nguyen
 
whats new in java 8
whats new in java 8 whats new in java 8
whats new in java 8 Dori Waldman
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentationVan Huong
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014Nayden Gochev
 
21UCAC31 Java Programming.pdf(MTNC)(BCA)
21UCAC31 Java Programming.pdf(MTNC)(BCA)21UCAC31 Java Programming.pdf(MTNC)(BCA)
21UCAC31 Java Programming.pdf(MTNC)(BCA)ssuser7f90ae
 
Java8: what's new and what's hot
Java8: what's new and what's hotJava8: what's new and what's hot
Java8: what's new and what's hotSergii Maliarov
 

Ähnlich wie Colloquium Report (20)

Introduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and StreamsIntroduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
 
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
 
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
 
Java 8-revealed
Java 8-revealedJava 8-revealed
Java 8-revealed
 
Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
 
New Features of JAVA SE8
New Features of JAVA SE8New Features of JAVA SE8
New Features of JAVA SE8
 
Java 8 - An Overview
Java 8 - An OverviewJava 8 - An Overview
Java 8 - An Overview
 
Java 8
Java 8Java 8
Java 8
 
Insight into java 1.8, OOP VS FP
Insight into java 1.8, OOP VS FPInsight into java 1.8, OOP VS FP
Insight into java 1.8, OOP VS FP
 
Functional programming in java 8 by harmeet singh
Functional programming in java 8 by harmeet singhFunctional programming in java 8 by harmeet singh
Functional programming in java 8 by harmeet singh
 
Towards Improving Interface Modularity in Legacy Java Software Through Automa...
Towards Improving Interface Modularity in Legacy Java Software Through Automa...Towards Improving Interface Modularity in Legacy Java Software Through Automa...
Towards Improving Interface Modularity in Legacy Java Software Through Automa...
 
Java 8 New features
Java 8 New featuresJava 8 New features
Java 8 New features
 
whats new in java 8
whats new in java 8 whats new in java 8
whats new in java 8
 
14274730 (1).ppt
14274730 (1).ppt14274730 (1).ppt
14274730 (1).ppt
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentation
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014
 
21UCAC31 Java Programming.pdf(MTNC)(BCA)
21UCAC31 Java Programming.pdf(MTNC)(BCA)21UCAC31 Java Programming.pdf(MTNC)(BCA)
21UCAC31 Java Programming.pdf(MTNC)(BCA)
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Java8: what's new and what's hot
Java8: what's new and what's hotJava8: what's new and what's hot
Java8: what's new and what's hot
 
Java 8 Intro - Core Features
Java 8 Intro - Core FeaturesJava 8 Intro - Core Features
Java 8 Intro - Core Features
 

Mehr von Mohammad Faizan

Mehr von Mohammad Faizan (15)

Tutorial c#
Tutorial c#Tutorial c#
Tutorial c#
 
Java 8 from perm gen to metaspace
Java 8  from perm gen to metaspaceJava 8  from perm gen to metaspace
Java 8 from perm gen to metaspace
 
SOFTWARE TESTING UNIT-4
SOFTWARE TESTING UNIT-4  SOFTWARE TESTING UNIT-4
SOFTWARE TESTING UNIT-4
 
Software maintenance Unit5
Software maintenance  Unit5Software maintenance  Unit5
Software maintenance Unit5
 
Jvm internal detail
Jvm internal detailJvm internal detail
Jvm internal detail
 
Unit2 Software engineering UPTU
Unit2 Software engineering UPTUUnit2 Software engineering UPTU
Unit2 Software engineering UPTU
 
hibernate with JPA
hibernate with JPAhibernate with JPA
hibernate with JPA
 
Allama Iqbal shiqwa with meaning
Allama Iqbal shiqwa with meaningAllama Iqbal shiqwa with meaning
Allama Iqbal shiqwa with meaning
 
Web tech chapter 1 (1)
Web tech chapter 1 (1)Web tech chapter 1 (1)
Web tech chapter 1 (1)
 
Mdm intro-chapter1
Mdm intro-chapter1Mdm intro-chapter1
Mdm intro-chapter1
 
Hill climbing
Hill climbingHill climbing
Hill climbing
 
Coda file system tahir
Coda file system   tahirCoda file system   tahir
Coda file system tahir
 
Chapter30 (1)
Chapter30 (1)Chapter30 (1)
Chapter30 (1)
 
Ai4 heuristic2
Ai4 heuristic2Ai4 heuristic2
Ai4 heuristic2
 
Chapter30
Chapter30Chapter30
Chapter30
 

Kürzlich hochgeladen

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesShubhangi Sonawane
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxNikitaBankoti2
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 

Kürzlich hochgeladen (20)

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 

Colloquium Report

  • 1. Colloquium Report Faizan, Mohammad | MCA | May 4, 2015 JAVA 8
  • 2. PAGE 1 Introduction JAVA 8 (JDK 1.8) is a major release of JAVA programming language development. Its initial version was released on 18 March 2014. With the Java 8 release, Java provided support for functional programming, new JavaScript engine, new APIs for date time manipulation, new streaming API, etc. New Features There are dozens of features added to Java 8, the most significant ones are mentioned below − Lambda expression − Adds functional processing capability to Java. Method references − Referencing functions by their names instead of invoking them directly. Using functions as parameter. Defaultmethod − Interface to have default method implementation. New tools − New compiler tools and utilities are added. Stream API − New stream API to facilitate pipeline processing. Date Time API − Improved date time API. Optional Class − Emphasis on best practices to handle null values properly. The Biggest thing in java 8 is functional programming that means with java we can not only object composition but we can also do functional composition. We can achieve functional programming with java 8 with Lambda expression.
  • 3. PAGE 2 Evolution • The lambda calculus was introduced in the 1930s by Alonzo Church as a mathematical system for defining computable functions. • The lambda calculus is equivalent in definitional power to that of Turing machines. • The lambda calculus serves as the computational model underlying functional programming languages such as Lisp, Haskell, and Ocaml • Features from the lambda calculus such as lambda expressions have been incorporated into many widely used programming languages like C++ and now very recently Java 8. What is Lambda Calculus The central concept in the lambda calculus is an expression generated by the following grammar which can denote a function definition, function application, variable, or parenthesized expression: expr → λ var . expr | expr expr | var | (expr) We can think of a lambda-calculus expression as a program which when evaluated by beta-reductions returns a result consisting of another lambda- calculus expression. Functional Programming A style of programming that treats computation as the evaluation of mathematical functions  Eliminates side effects  Treats data as being immutable  Expressions have referential transparency  Functions can take functions as arguments and return functions as results  Prefers recursion over explicit for-loops
  • 4. PAGE 3 Methods with Case study 1. Java 8 is the biggest change to Java since the inception of the language 2. Lambdas are the most important new addition 3. Java is playing catch-up: most major programming languages already have support for lambda expressions 4. A big challenge was to introduce lambdas without requiring recompilation of existing binaries Lambda and Functional Interface Lambdas (also known as closures) are the biggest and most awaited language change in the whole Java 8 release. They allow us to treat functionality as a method argument (passing functions around), or treat a code as data: the concepts every functional developer is very familiar with. Many languages on JVM platform (Groovy, Scala, …) have had lambdas since day one, but Java developers had no choice but hammer the lambdas with boilerplate anonymous classes. Lambdas design discussions have taken a lot of time and community efforts. But finally, the trade-offs have been found, leading to new concise and compact language constructs. In its simplest form, a lambda could be represented as a comma-separated list of parameters, the –> symbol and the body. For example: 1 Arrays.asList( "a", "b", "d" ).forEach( e -> System.out.println( e ) );
  • 5. PAGE 4 Default and Static Method Java 8 extends interface declarations with two new concepts: default and static methods. Default methods make interfaces somewhat similar to traits but serve a bit different goal. They allow adding new methods to existing interfaces without breaking the binary compatibility with the code written for older versions of those interfaces. The difference between default methods and abstract methods is that abstract methods are required to be implemented. But default methods are not. Instead, each interface must provide so called default implementation and all the implementers will inherit it by default (with a possibility to override this default implementation if needed). Let us take a look on example below. private interface Defaulable { // Interfaces now allow default methods, the implementer may or // may not implement (override) them. default String notRequired () { return "Default implementation"; } } private static class DefaultableImpl implements Defaulable { } private static class OverridableImpl implements Defaulable{ @Override public String notRequired() { return "Overridden implementation"; } }
  • 6. PAGE 5 Method References Method references provide the useful syntax to refer directly to exiting methods or constructors of Java classes or objects (instances). With conjunction of Lambdas expressions, method references make the language constructs look compact and concise, leaving off boilerplate. Below, considering the class Car as an example of different method definitions, let us distinguish four supported types of method references. public class FunctionalStyle { public static void main (String [] args) { List<Integer> values = Arrays.asList(1, 2, 3, 4, 5, 6); System.out.println(" With for iterator"); int total = 0; for (int e: values) { total += e*2; } System.out.println(total); values. stream () . map(e->e*2) . reduce (0, (c,e)->c+e).forEach(System.out::print); } }
  • 7. PAGE 6 Repeatingannotations Since Java 5 introduced the annotations support, this feature became very popular and is very widely used. However, one of the limitations of annotation usage was the fact that the same annotation cannot be declared more than once at the same location. Java 8 breaks this rule and introduced the repeating annotations. It allows the same annotation to be repeated several times in place it is declared. @Color(name = "Red") @Color(name = "Blue") @Color(name = "Black") public class Shirt { public static void main(String[] args) { Color[] colors = Shirt.class.getAnnotationsByType(Color.class); for (Color cl : colors ) System.out.println(cl.name()); } } Better Type Inference Java 8 compiler has improved a lot on type inference. In many cases the explicit type parameters could be inferred by compiler keeping the code cleaner. Let us take a look on one of the examples. public class Boundary { public void hello(String name, int age) { } public static void main(String[] args) { Method[] methods = Boundary.class.getMethods(); for (Method method : methods) { System.out.print(method.getName() + "("); Parameter[] parameters = method.getParameters(); for (Parameter parameter : parameters) {
  • 8. PAGE 7 System.out.print(parameter.getType().getName() + " " + parameter.getName() + " "); } System.out.println(")"); } } } Optional Class The famous NullPointerException is by far the most popular cause of Java application failures. Long time ago the great Google project introduced the Optional as a solution to NullPointerExceptions, discouraging codebase pollution with null checks and encouraging developers to write cleaner code. Inspired by Google Guava, the Optional is now a part of Java 8 library. Optional is just a container: it can hold a value of some type T or just be null. It provides a lot of useful methods so the explicit null checks have no excuse anymore. Please refer to official Java 8 documentation for more details. We are going to take a look on two small examples of Optional usages: with the null able value and with the value which does not allow nulls. Streams The newly added Stream API (java.util.stream) introduces real-world functional-style programming into the Java. This is by far the most comprehensive addition to Java library intended to make Java developers significantly more productive by allowing them to write effective, clean, and concise code. Stream API makes collections processing greatly simplified (but it is not limited to Java collections only as we will see later). Let us take start off with simple class called Task.
  • 9. PAGE 8 public class ParallelStreams { public static void main(String[] args) { List<Integer> numbers = Arrays.asList(1,2,3,4,5,6,7,8,10); System.out.println("With Stream"); numbers.stream() .forEach(e -> System.out.print(e + " ")); System.out.println(" nWith parallelStream : 1"); numbers.parallelStream() .forEach(e -> System.out.print(e + " ")); System.out.println("nWith parallelStream : 2"); numbers.parallelStream() .forEach(e -> System.out.print(e + " ")); System.out.println("nWith parallelStream : 3"); numbers.parallelStream() .forEach(e -> System.out.print(e + " ")); } }
  • 10. PAGE 9 Base64 Finally, the support of Base64 encoding has made its way into Java standard library with Java 8 release. It is very easy to use as following example shows off. The particular set of 64 characters chosen to represent the 64 place-values for the base varies between implementations. The general strategy is to choose 64 characters that are both members of a subset common to most encodings, and also printable. This combination leaves the data unlikely to be modified in transit through information systems, such as email, that were traditionally not 8-bit clean public class Base64s { public static void main (String [] args) { String text = "Base 64 Finally In Java"; String encode = Base64.getEncoder() .encodeToString(text.getBytes(StandardCharsets.US_ASCII)); System.out.println(encode); String decode = new String( Base64.getDecoder().decode(encode) , StandardCharsets.US_ASCII ); System.out.println(decode); } } New Features in Java runtime (JVM) The PermGen space is gone and has been replaced with Metaspace . The JVM options -XX:PermSize and –XX:MaxPermSize have been replaced by - XX:MetaSpaceSize and -XX:MaxMetaspaceSize respectively.
  • 11. PAGE 10 Conclusion The future is here: Java 8 moves this great platform forward by delivering the features to make developers much more productive. It is too early to move the production systems to Java 8 but in the next couples of months its adoption should slowly start growing. Nevertheless, the time is right to start preparing your code bases to be compatible with Java 8 and to be ready to turn the switch once Java 8 proves to be safe and stable enough. As a confirmation of community Java 8 acceptance, recently Pivotal Released Spring Framework 4.0.3 with production-ready Java 8 support. Resources Some additional resources which discuss in depth different aspects of Java 8 features:  What’s New in JDK 8: http://www.oracle.com/technetwork/java/javase/8-whats- new-2157071.html  The Java Tutorials: http://docs.oracle.com/javase/tutorial/  WildFly 8, JDK 8, NetBeans 8, Java EE 7: http://blog.arungupta.me/2014/03/wildfly8-jdk8-netbeans8-javaee7-excellent- combo-enterprise-java/  Java 8 Tutorial: http://winterbe.com/posts/2014/03/16/java-8-tutorial/  JDK 8 Command-line Static Dependency Checker: http://marxsoftware.blogspot.ca/2014/03/jdeps.html  The Illuminating Javadoc of JDK 8: http://marxsoftware.blogspot.ca/2014/03/illuminating-javadoc-of-jdk-8.html  The Dark Side of Java 8: http://blog.jooq.org/2014/04/04/java-8-friday-the-dark- side-of-java-8/
  • 12. PAGE 11  Installing Java™ 8 Support in Eclipse Kepler SR2: http://www.eclipse.org/downloads/java8/  Java 8: http://www.baeldung.com/java8  Oracle Natron. A Next-Generation JavaScript Engine for the JVM: http://www.oracle.com/technetwork/articles/java/jf14-nashorn- 2126515.html