SlideShare a Scribd company logo
9 new features in Java 99 NEW FEATURES IN JAVA.
1. The Java Platform module system
2. Linking
3. JShell: the interactive Java REPL
4. Improved Javadoc
5.Stream API improvements
6.Private interface methods
7.HTTP/2
8.Multi-release JARs
9.Collection factory methods
1. The Java Platform module system
The defining feature for Java 9 is an all-new module system.When codebases grow
the odds of creating complicated,tangled “spaghetti code” increase exponentially.
There are two fundamental problems:
1.It is hard to truly encapsulate code,
and there is no notion of explicit dependencies between different parts (JAR files) of a system
2.Every public class can be accessed by any other public class on the classpath,
leading to inadvertent usage of classes that weren't meant to be public API
2. Linking
When you have modules with explicit dependencies,and a modularized J
new possibilities arise.
Your application modules now state their dependencies on other
application modules and on the modules it uses from the JDK
Why not use that information to create a minimal runtime environment,
containing just those modules necessary to run your application?
That's made possible with the new jlink tool in Java 9.
Instead of shipping your app with a fully loaded JDK installation,
you can create a minimal runtime image optimized for your application.
3. JShell: the interactive Java REPL3
Many languages already feature an interactive Read-Eval-Print-Loop, and Java now joins this club.
You can launch jshell from the console and directly start typing and executing Java code.
The immediate feedback of jshell makes it a great tool to explore APIs and try out language features
Testing a Java regular expression is a great example of how jshell can make your life easier.
The interactive shell also makes for a great teaching environment and productivity boost,
which you can learn more about in this webinar
public static void main(String[] args)` nonsense is all about when teaching people how to code Java.
4. Improved Javadoc
Sometimes it's the little things that can make a big difference. Did you useGoogle all the time to
the right Javadoc pages, just like me?hat's no longer necessary. Javadoc now includes search right
the API documentation itself.As an added bonus, the Javadoc output is now HTML5 compliant. Also
you'll notice that every Javadoc page includes information on which JDK module
the class or interface comes from.
5. Collection factory methods
Often you want to create a collection in your code and directly pop
it with some elements That leads to repetitive codwhere you instan
the collection, followed by several `add` calls.
With Java 9, several so-called collection factory methods have
been added:
Set<Integer> ints = Set.of(1, 2, 3);
List<String> strings = List.of("first", "second");
Besides being shorter and nicer to read, these methods
also relieve you from having to pick a specific collection implement
In fact, the collection implementations returned from the factory me
are highly optimized for the number of elements you put in.
That's possible because they're immutable:
adding items to these collections after creation results in an
`UnsupportedOperationException`.
6. Stream API improvements:
The Streams API is arguably one of the best improvements to
the Javastandard library in a long time. It allows you to
Create declarativepipelines of transformations on collections.
With Java 9, this only gets better. There are four new methods add
to the Stream interface:
dropWhile, takeWhile, ofNullable. The iterate method gets a new
overload,allowing you to provide a Predicate on when to stop
Iterating:
IntStream.iterate(1, i -> i < 100, i -> i + 1).forEach(System.out::printl
The second argument is a lambda that returns true until the current
element in the IntStream becomes 100. This simple example therefo
prints the integers 1 until 99 on the console.
7. Private interface methods
Java 8 brought us default methods on interfaces. An interface can now also contain behavior
Instead of only method signatures. But what happens if you have several default methods on an
interface
with code that does almost the same thing? Normally, you'd refactor those methods to call a priv
method containing the shared functionality. But default methods can't be private.
Creating another default method with the shared code is not a solution, because this helper met
becomes part of the public API. With Java 9, you can add private helper methods to interfaces to
solve this problem:
public interface MyInterface {
void normalInterfaceMethod();
default void interfaceMethodWithDefault() { init(); }
default void anotherDefaultMethod() { init(); }
// This method is not part of the public API exposed by MyInterface
private void init() { System.out.println("Initializing"); }
}
8. HTTP/2
A new way of performing HTTP calls arrives with Java 9. This much overdue replacement for the old
HttpURLConnection` API also supports WebSockets and HTTP/2 out of the box. One caveat:
The new HttpClient API is delivered as a so-called _incubator module_ in Java 9.
This means the API isn't guaranteed to be 100% final yet. Still, with the arrival of
Java 9 you can already start using this API:
HttpClient client = HttpClient.newHttpClient();
HttpRequest req =
HttpRequest.newBuilder(URI.create("http://www.google.com"))
.header("User-Agent","Java")
.GET()
.build();
HttpResponse<String> resp = client.send(req, HttpResponse.BodyHandler.asString());
9. Multi-release JARs
The last feature we're highlighting is especially good news for library maintainers. When a newversio
of Java comes out, it takes years for all users of your library to switch to this new version.
That means the library has to be backward compatible with the oldest version of Java
you want to support (e.g., Java 6 or 7 in many cases).
That effectively means you won't get to use the new features of Java 9 in your library for a long time.
Fortunately, the multi-release JAR feature allows you to create alternate versions of classes that are
only used when running the library on a specific Java version:
multirelease.jar
├── META-INF
│ └── versions
│ └── 9
│ └── multirelease
│ └── Helper.class
├── multirelease
├── Helper.class
└── Main.class
n this case, multirelease.jar can be used on Java 9, where instead of the top-level multirelease.
Helper class, the one under `META-INF/versions/9` is used. This Java 9-specific
version of the class can use Java 9 features and libraries. At the same time, using this JAR on earlier
Java versions still works, since the older Java versions only see the top-level Helper class.

More Related Content

What's hot

Replicating production on your laptop using the magic of containers
Replicating production on your laptop using the magic of containersReplicating production on your laptop using the magic of containers
Replicating production on your laptop using the magic of containers
Jamie Coleman
 
Glassfish JEE Server Administration - Clustering
Glassfish JEE Server Administration - ClusteringGlassfish JEE Server Administration - Clustering
Glassfish JEE Server Administration - Clustering
Danairat Thanabodithammachari
 
JEE Programming - 04 Java Servlets
JEE Programming - 04 Java ServletsJEE Programming - 04 Java Servlets
JEE Programming - 04 Java Servlets
Danairat Thanabodithammachari
 
Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud
Shekhar Gulati
 
Springboot2 postgresql-jpa-hibernate-crud-example with test
Springboot2 postgresql-jpa-hibernate-crud-example with testSpringboot2 postgresql-jpa-hibernate-crud-example with test
Springboot2 postgresql-jpa-hibernate-crud-example with test
HyukSun Kwon
 
ScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency InjectionScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency Injection
7mind
 
JEE Programming - 07 EJB Programming
JEE Programming - 07 EJB ProgrammingJEE Programming - 07 EJB Programming
JEE Programming - 07 EJB Programming
Danairat Thanabodithammachari
 
Spring boot
Spring bootSpring boot
Spring boot
Gyanendra Yadav
 
Hyper-pragmatic Pure FP testing with distage-testkit
Hyper-pragmatic Pure FP testing with distage-testkitHyper-pragmatic Pure FP testing with distage-testkit
Hyper-pragmatic Pure FP testing with distage-testkit
7mind
 
Gwt portlet
Gwt portletGwt portlet
Gwt portlet
prabakaranbrick
 
Glassfish JEE Server Administration - JEE Introduction
Glassfish JEE Server Administration - JEE IntroductionGlassfish JEE Server Administration - JEE Introduction
Glassfish JEE Server Administration - JEE Introduction
Danairat Thanabodithammachari
 
MuleSoft ESB Testing Mule Application using MUnit Test Suite
MuleSoft ESB Testing Mule Application using MUnit Test SuiteMuleSoft ESB Testing Mule Application using MUnit Test Suite
MuleSoft ESB Testing Mule Application using MUnit Test Suite
akashdprajapati
 
Complete steps to Integrate Push Notification for Your Cocos2dx App with Push...
Complete steps to Integrate Push Notification for Your Cocos2dx App with Push...Complete steps to Integrate Push Notification for Your Cocos2dx App with Push...
Complete steps to Integrate Push Notification for Your Cocos2dx App with Push...
ShepHertz
 
JEE Programming - 08 Enterprise Application Deployment
JEE Programming - 08 Enterprise Application DeploymentJEE Programming - 08 Enterprise Application Deployment
JEE Programming - 08 Enterprise Application Deployment
Danairat Thanabodithammachari
 
JEE Programming - 05 JSP
JEE Programming - 05 JSPJEE Programming - 05 JSP
JEE Programming - 05 JSP
Danairat Thanabodithammachari
 
How to customize Spring Boot?
How to customize Spring Boot?How to customize Spring Boot?
How to customize Spring Boot?
GilWon Oh
 
Project Presentation on Advance Java
Project Presentation on Advance JavaProject Presentation on Advance Java
Project Presentation on Advance Java
Vikas Goyal
 
Glassfish JEE Server Administration - Module 4 Load Balancer
Glassfish JEE Server Administration - Module 4 Load BalancerGlassfish JEE Server Administration - Module 4 Load Balancer
Glassfish JEE Server Administration - Module 4 Load Balancer
Danairat Thanabodithammachari
 
Creating Sentiment Line Chart with Watson
Creating Sentiment Line Chart with Watson Creating Sentiment Line Chart with Watson
Creating Sentiment Line Chart with Watson
Dev_Events
 
Spring boot
Spring bootSpring boot
Spring boot
Bhagwat Kumar
 

What's hot (20)

Replicating production on your laptop using the magic of containers
Replicating production on your laptop using the magic of containersReplicating production on your laptop using the magic of containers
Replicating production on your laptop using the magic of containers
 
Glassfish JEE Server Administration - Clustering
Glassfish JEE Server Administration - ClusteringGlassfish JEE Server Administration - Clustering
Glassfish JEE Server Administration - Clustering
 
JEE Programming - 04 Java Servlets
JEE Programming - 04 Java ServletsJEE Programming - 04 Java Servlets
JEE Programming - 04 Java Servlets
 
Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud
 
Springboot2 postgresql-jpa-hibernate-crud-example with test
Springboot2 postgresql-jpa-hibernate-crud-example with testSpringboot2 postgresql-jpa-hibernate-crud-example with test
Springboot2 postgresql-jpa-hibernate-crud-example with test
 
ScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency InjectionScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency Injection
 
JEE Programming - 07 EJB Programming
JEE Programming - 07 EJB ProgrammingJEE Programming - 07 EJB Programming
JEE Programming - 07 EJB Programming
 
Spring boot
Spring bootSpring boot
Spring boot
 
Hyper-pragmatic Pure FP testing with distage-testkit
Hyper-pragmatic Pure FP testing with distage-testkitHyper-pragmatic Pure FP testing with distage-testkit
Hyper-pragmatic Pure FP testing with distage-testkit
 
Gwt portlet
Gwt portletGwt portlet
Gwt portlet
 
Glassfish JEE Server Administration - JEE Introduction
Glassfish JEE Server Administration - JEE IntroductionGlassfish JEE Server Administration - JEE Introduction
Glassfish JEE Server Administration - JEE Introduction
 
MuleSoft ESB Testing Mule Application using MUnit Test Suite
MuleSoft ESB Testing Mule Application using MUnit Test SuiteMuleSoft ESB Testing Mule Application using MUnit Test Suite
MuleSoft ESB Testing Mule Application using MUnit Test Suite
 
Complete steps to Integrate Push Notification for Your Cocos2dx App with Push...
Complete steps to Integrate Push Notification for Your Cocos2dx App with Push...Complete steps to Integrate Push Notification for Your Cocos2dx App with Push...
Complete steps to Integrate Push Notification for Your Cocos2dx App with Push...
 
JEE Programming - 08 Enterprise Application Deployment
JEE Programming - 08 Enterprise Application DeploymentJEE Programming - 08 Enterprise Application Deployment
JEE Programming - 08 Enterprise Application Deployment
 
JEE Programming - 05 JSP
JEE Programming - 05 JSPJEE Programming - 05 JSP
JEE Programming - 05 JSP
 
How to customize Spring Boot?
How to customize Spring Boot?How to customize Spring Boot?
How to customize Spring Boot?
 
Project Presentation on Advance Java
Project Presentation on Advance JavaProject Presentation on Advance Java
Project Presentation on Advance Java
 
Glassfish JEE Server Administration - Module 4 Load Balancer
Glassfish JEE Server Administration - Module 4 Load BalancerGlassfish JEE Server Administration - Module 4 Load Balancer
Glassfish JEE Server Administration - Module 4 Load Balancer
 
Creating Sentiment Line Chart with Watson
Creating Sentiment Line Chart with Watson Creating Sentiment Line Chart with Watson
Creating Sentiment Line Chart with Watson
 
Spring boot
Spring bootSpring boot
Spring boot
 

Similar to Features java9

Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
Nicola Pedot
 
It's always your fault
It's always your faultIt's always your fault
It's always your fault
Przemek Jakubczyk
 
Laravel 6 and its features
Laravel 6 and its featuresLaravel 6 and its features
Laravel 6 and its features
SudabaSolaimankhil
 
java new technology
java new technologyjava new technology
java new technology
chavdagirimal
 
Java 9 features
Java 9 featuresJava 9 features
Java 9 features
shrinath97
 
Top 5 features added to Java 9
Top 5 features added to Java 9Top 5 features added to Java 9
Top 5 features added to Java 9
Ankur Srivastava
 
Colloquium Report
Colloquium ReportColloquium Report
Colloquium Report
Mohammad Faizan
 
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
Amit Singh
 
Java 8 - Completable Future
Java 8 - Completable FutureJava 8 - Completable Future
Java 8 - Completable Future
Sajad jafari
 
Java bad coding practices
Java bad coding practicesJava bad coding practices
Java bad coding practices
Gustavo Carrion, MiT
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
hchen1
 
Jquery Plugin
Jquery PluginJquery Plugin
Jquery Plugin
Ravi Mone
 
Xml messaging with soap
Xml messaging with soapXml messaging with soap
Xml Messaging With Soap
Xml Messaging With SoapXml Messaging With Soap
Xml Messaging With Soap
AkramWaseem
 
Xml messaging with soap
Xml messaging with soapXml messaging with soap
Xml messaging with soap
Johnny Pork
 
It's always your fault. Poznań ADG 2016
It's always your fault. Poznań ADG 2016It's always your fault. Poznań ADG 2016
It's always your fault. Poznań ADG 2016
Przemek Jakubczyk
 
Follow these reasons to know java’s importance
Follow these reasons to know java’s importanceFollow these reasons to know java’s importance
Follow these reasons to know java’s importance
nishajj
 
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
Emiel Paasschens
 
JAVA INTRODUCTION
JAVA INTRODUCTIONJAVA INTRODUCTION
JAVA INTRODUCTION
Prof Ansari
 
JAVA INTRODUCTION
JAVA INTRODUCTIONJAVA INTRODUCTION
JAVA INTRODUCTION
Prof Ansari
 

Similar to Features java9 (20)

Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
 
It's always your fault
It's always your faultIt's always your fault
It's always your fault
 
Laravel 6 and its features
Laravel 6 and its featuresLaravel 6 and its features
Laravel 6 and its features
 
java new technology
java new technologyjava new technology
java new technology
 
Java 9 features
Java 9 featuresJava 9 features
Java 9 features
 
Top 5 features added to Java 9
Top 5 features added to Java 9Top 5 features added to Java 9
Top 5 features added to Java 9
 
Colloquium Report
Colloquium ReportColloquium Report
Colloquium Report
 
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
 
Java 8 - Completable Future
Java 8 - Completable FutureJava 8 - Completable Future
Java 8 - Completable Future
 
Java bad coding practices
Java bad coding practicesJava bad coding practices
Java bad coding practices
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
 
Jquery Plugin
Jquery PluginJquery Plugin
Jquery Plugin
 
Xml messaging with soap
Xml messaging with soapXml messaging with soap
Xml messaging with soap
 
Xml Messaging With Soap
Xml Messaging With SoapXml Messaging With Soap
Xml Messaging With Soap
 
Xml messaging with soap
Xml messaging with soapXml messaging with soap
Xml messaging with soap
 
It's always your fault. Poznań ADG 2016
It's always your fault. Poznań ADG 2016It's always your fault. Poznań ADG 2016
It's always your fault. Poznań ADG 2016
 
Follow these reasons to know java’s importance
Follow these reasons to know java’s importanceFollow these reasons to know java’s importance
Follow these reasons to know java’s importance
 
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
 
JAVA INTRODUCTION
JAVA INTRODUCTIONJAVA INTRODUCTION
JAVA INTRODUCTION
 
JAVA INTRODUCTION
JAVA INTRODUCTIONJAVA INTRODUCTION
JAVA INTRODUCTION
 

Recently uploaded

Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
What is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptxWhat is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptx
christianmathematics
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
NelTorrente
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
ArianaBusciglio
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 

Recently uploaded (20)

Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
What is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptxWhat is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptx
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 

Features java9

  • 1. 9 new features in Java 99 NEW FEATURES IN JAVA. 1. The Java Platform module system 2. Linking 3. JShell: the interactive Java REPL 4. Improved Javadoc 5.Stream API improvements 6.Private interface methods 7.HTTP/2 8.Multi-release JARs 9.Collection factory methods
  • 2. 1. The Java Platform module system The defining feature for Java 9 is an all-new module system.When codebases grow the odds of creating complicated,tangled “spaghetti code” increase exponentially. There are two fundamental problems: 1.It is hard to truly encapsulate code, and there is no notion of explicit dependencies between different parts (JAR files) of a system 2.Every public class can be accessed by any other public class on the classpath, leading to inadvertent usage of classes that weren't meant to be public API
  • 3. 2. Linking When you have modules with explicit dependencies,and a modularized J new possibilities arise. Your application modules now state their dependencies on other application modules and on the modules it uses from the JDK Why not use that information to create a minimal runtime environment, containing just those modules necessary to run your application? That's made possible with the new jlink tool in Java 9. Instead of shipping your app with a fully loaded JDK installation, you can create a minimal runtime image optimized for your application.
  • 4. 3. JShell: the interactive Java REPL3 Many languages already feature an interactive Read-Eval-Print-Loop, and Java now joins this club. You can launch jshell from the console and directly start typing and executing Java code. The immediate feedback of jshell makes it a great tool to explore APIs and try out language features Testing a Java regular expression is a great example of how jshell can make your life easier. The interactive shell also makes for a great teaching environment and productivity boost, which you can learn more about in this webinar public static void main(String[] args)` nonsense is all about when teaching people how to code Java.
  • 5. 4. Improved Javadoc Sometimes it's the little things that can make a big difference. Did you useGoogle all the time to the right Javadoc pages, just like me?hat's no longer necessary. Javadoc now includes search right the API documentation itself.As an added bonus, the Javadoc output is now HTML5 compliant. Also you'll notice that every Javadoc page includes information on which JDK module the class or interface comes from.
  • 6. 5. Collection factory methods Often you want to create a collection in your code and directly pop it with some elements That leads to repetitive codwhere you instan the collection, followed by several `add` calls. With Java 9, several so-called collection factory methods have been added: Set<Integer> ints = Set.of(1, 2, 3); List<String> strings = List.of("first", "second"); Besides being shorter and nicer to read, these methods also relieve you from having to pick a specific collection implement In fact, the collection implementations returned from the factory me are highly optimized for the number of elements you put in. That's possible because they're immutable: adding items to these collections after creation results in an `UnsupportedOperationException`.
  • 7. 6. Stream API improvements: The Streams API is arguably one of the best improvements to the Javastandard library in a long time. It allows you to Create declarativepipelines of transformations on collections. With Java 9, this only gets better. There are four new methods add to the Stream interface: dropWhile, takeWhile, ofNullable. The iterate method gets a new overload,allowing you to provide a Predicate on when to stop Iterating: IntStream.iterate(1, i -> i < 100, i -> i + 1).forEach(System.out::printl The second argument is a lambda that returns true until the current element in the IntStream becomes 100. This simple example therefo prints the integers 1 until 99 on the console.
  • 8. 7. Private interface methods Java 8 brought us default methods on interfaces. An interface can now also contain behavior Instead of only method signatures. But what happens if you have several default methods on an interface with code that does almost the same thing? Normally, you'd refactor those methods to call a priv method containing the shared functionality. But default methods can't be private. Creating another default method with the shared code is not a solution, because this helper met becomes part of the public API. With Java 9, you can add private helper methods to interfaces to solve this problem: public interface MyInterface { void normalInterfaceMethod(); default void interfaceMethodWithDefault() { init(); } default void anotherDefaultMethod() { init(); } // This method is not part of the public API exposed by MyInterface private void init() { System.out.println("Initializing"); } }
  • 9. 8. HTTP/2 A new way of performing HTTP calls arrives with Java 9. This much overdue replacement for the old HttpURLConnection` API also supports WebSockets and HTTP/2 out of the box. One caveat: The new HttpClient API is delivered as a so-called _incubator module_ in Java 9. This means the API isn't guaranteed to be 100% final yet. Still, with the arrival of Java 9 you can already start using this API: HttpClient client = HttpClient.newHttpClient(); HttpRequest req = HttpRequest.newBuilder(URI.create("http://www.google.com")) .header("User-Agent","Java") .GET() .build(); HttpResponse<String> resp = client.send(req, HttpResponse.BodyHandler.asString());
  • 10. 9. Multi-release JARs The last feature we're highlighting is especially good news for library maintainers. When a newversio of Java comes out, it takes years for all users of your library to switch to this new version. That means the library has to be backward compatible with the oldest version of Java you want to support (e.g., Java 6 or 7 in many cases). That effectively means you won't get to use the new features of Java 9 in your library for a long time. Fortunately, the multi-release JAR feature allows you to create alternate versions of classes that are only used when running the library on a specific Java version: multirelease.jar ├── META-INF │ └── versions │ └── 9 │ └── multirelease │ └── Helper.class ├── multirelease ├── Helper.class └── Main.class n this case, multirelease.jar can be used on Java 9, where instead of the top-level multirelease. Helper class, the one under `META-INF/versions/9` is used. This Java 9-specific version of the class can use Java 9 features and libraries. At the same time, using this JAR on earlier Java versions still works, since the older Java versions only see the top-level Helper class.