Showing posts with label Java9. Show all posts
Showing posts with label Java9. Show all posts
Sunday, 8 January 2017
Complete Java 9 Module System Tutorials
Thursday, 13 October 2016
Complete Java SE 9: New Features Tutorial
As per latest new by Jan 2017, Oracle Corp is going to release JDK 9 by July 2017.
Introduction
Oracle Corporation is going to release Java New Version: Java SE 9 around End of March 2017.
So, I would like to deliver a serious of Posts on Java SE 9 New Features.
Introduction Java SE 9 New Features
Java SE 9 New Features List:
- REPL (JShell)
- Private Methods in Interfaces
- var for Local Variables
- Factory Methods to Immutable List, Set and Map
- Reactive Programming
- Module System
- Try-With-Resource Enhancements
- Stream API Changes
- Process API Changes
- Optional API Changes
- Type Inference Enhancements
- Security Enhancements
- Garbage Collector Enhancements
And More.
Java SE 9 New Features
I have already delivered couple of posts on Java SE 9 New Features in Journal DEV website. Please read them below :
In-Depth Tutorials:
- Java SE 9: REPL Basics
- Java SE 9: Private methods in Interface
- Java SE 9: “var” for local variables
- Java SE 9: Factory Methods for Immutable List
- Java SE9: REPL (JShell) Features and Examples (Part-2)
- Java SE 9: Factory Methods for Immutable Set
- Java SE 9: Factory Methods for Immutable Map and Map.Entry
- Java SE 9: Try-With-Resource Improvements
- Java SE 9: Stream API Improvements
- Java SE 9: Optional API Improvements
- Java SE 9: Process API Improvements
- Java SE 9: "_" (Underscore) Changes
- Java SE 9: Introduction to Reactive Programming
- Java SE 9: Reactive Modules
- Java SE 9: Module System
IN PROGRESS
Please click on those links to access them. Visit this page for updates of new posts.
That’s it all about Java SE 9 New Features. We will discuss some more Java SE 9 New Features in my coming posts.
Please drop me a comment if you like my post or have any issues/suggestions/type errors.
Thank you for reading my tutorials.
Happy Java SE 9 Learning!
Monday, 19 September 2016
Java 9: "var" for local variables. Improvement in Type Inference
Post Brief Table of Content
- Introduction
- Java 9 var Basics
- Is var a keyword?
- Type Inference Improvements
- Advantages of this Feature
Introduction
Before reading this post, please go through my previous Java 9 New Features posts.
In this post, we are going to discuss about "var" new identifier and some Type Inference improvement to support this new identifier.
NOTE:- IN PROGRESS
Will update some more points soon.
In this post, we are going to discuss about "var" new identifier and some Type Inference improvement to support this new identifier.
NOTE:- IN PROGRESS
Will update some more points soon.
Java 9 var Basics
The main aim of this change is : Local-Variable Type Inference
This change is implementing as part of JEP 286.
Example:-
Before Java 9:
-> List<> marksList = new ArrayList<Int>();
Here we are should use either List<Int> or List<> (Diamond operator introduced in Java SE 7) to define local variables.
Here Java Compiler is able to infer only type parameter.
In Java 9:
Please drop me a comment if you like my post or have any issues/suggestions. I love your valuable comments so much.
Here Java Compiler is able to infer only type parameter.
In Java 9:
-> var marksList = new ArrayList<Int>();
Here we are defining just var and variable name that's it.
Here Java Compiler is able to infer whole reference type. Here Java Compiler will infer the type of marksList as ArrayList<Int> only, but not List<Int> .
Java 9 Compiler will infer the type based on the type definition available at RHS Side.
When we use var identifier like this to define local variables, compiler will infer it's type automatically.
NOTE:-
The type is inferred based on the type of the initializer. If there is no initializer, the initializer is the null literal, or the type of the initializer is not one that can be normalized to a suitable denotable type.
However any class name or interface will affect this change.
Here Java Compiler is able to infer whole reference type. Here Java Compiler will infer the type of marksList as ArrayList<Int> only, but not List<Int> .
Java 9 Compiler will infer the type based on the type definition available at RHS Side.
-> var runnable = new Runnable() { ... }
NOTE:-
The type is inferred based on the type of the initializer. If there is no initializer, the initializer is the null literal, or the type of the initializer is not one that can be normalized to a suitable denotable type.
Is var a Keyword?
In Java SE 9, "var" is not a keyword. It is a Reserved Type name. That means if our existing code uses var as a variable name, method name, or package name, then they do NOT effect with this change.However any class name or interface will affect this change.
Type Inference Improvements
Java SE 9 is going to introduce "var" identifier to define local variables with some improvement of Type Inference.
As we discussed in the above section, Java Compiler will analyse right hand side definition and automatically infer the reference type.
Advantages of this improvement
Because of this new feature in Java 9, we will get the following benefits:
- Avoid writing boilerplate code
- Improve some Readability (Some time reduce Readability).
NOTE:-
They are considering val also to include into the language soon.
Like Scala supports "var" and "val", Java 9 is also trying to include those constructs to improved Java Programming language.
However, Scala uses:
- var to define variables or mutable data
- val to define values or immutable data
That’s it all about “Java 9 var identifier”. We will discuss some more Java 9 New Features Concepts in my coming posts.
Monday, 30 November 2015
Java SE 9 Installation and REPL Tutorial
Oracle Corporation has planned to release Java SE 9 around Mid of September 2016 with lot of new Features and Enhancements to existing features.
Oracle Corporation is trying to integrate most of Scala Features into Java. They have already integrated some Functional Programming Features as part of Java SE 8.
Oracle has planned to integrate that REPL feature in Java SE 9. We are going to discuss Java 9 REPL with some simple examples in this post.
Please click on the following link to learn about Java 9 REPL with simple examples:
Java 9 Installation
Java 9 REPL Examples
Thanks for visiting my blog. I Love your comments and suggestions.
Happy Java 9 Learning!
Oracle Corporation is trying to integrate most of Scala Features into Java. They have already integrated some Functional Programming Features as part of Java SE 8.
Oracle has planned to integrate that REPL feature in Java SE 9. We are going to discuss Java 9 REPL with some simple examples in this post.
Please click on the following link to learn about Java 9 REPL with simple examples:
Java 9 Installation
Java 9 REPL Examples
Thanks for visiting my blog. I Love your comments and suggestions.
Happy Java 9 Learning!
Wednesday, 6 August 2014
Java 9 Features
Java 9 Features
- Project Valhalla
- Project Sumatra
- JNI (Java Native Interface) 2.0
- Collections Enhancements to support BigData
- Process API
- Contended Locking Enhancements
- Segmented Code Cache
- Light-Weight JSON API
- sjavac (Smart Java Compiler) Enhancements
- Project Jigsaw - Modularize JDK Source Code
- HTTP2 Client
- Money and Currency API
- REPL in Java
Project Valhalla
It all about Java Generics. It allows to use primitives in Generics to avoid type erasure issues.
Example:-
List<int> list = new ArrayList<>();
Modularize JDK Source Code
Reorganize the JDK source code into modules, enhance the build system to compile modules, and enforce module boundaries at build time.
Smart Java Compiler(sjavc) Enhancements
Improve the
Light-weight JSON API
Provide a light-weight API for consuming and generating JSON documents and data streams.
Segmented Code Cache
Divide the code cache into distinct segments, each of which contains compiled code of a particular type, in order to improve performance and enable future extensions.
Process API
Improve the API for controlling and managing operating-system processes.
Contented Locking Enhancements
Improve the performance of contended Java object monitors.
HTTP2 Client
Http client for HTTP2 and WebSockets
REPL in Java
REPL stands for Read-Evaluate-Print-Loop.
Like other languages, Java will also have a REPL to test it very quickly.
Modularize JDK Source Code
Reorganize the JDK source code into modules, enhance the build system to compile modules, and enforce module boundaries at build time.
Smart Java Compiler(sjavc) Enhancements
Improve the
sjavac tool so that it can be used by default in the JDK build, and generalize it so that it can be used to build large projects other than the JDK.Light-weight JSON API
Provide a light-weight API for consuming and generating JSON documents and data streams.
Segmented Code Cache
Divide the code cache into distinct segments, each of which contains compiled code of a particular type, in order to improve performance and enable future extensions.
Process API
Improve the API for controlling and managing operating-system processes.
Contented Locking Enhancements
Improve the performance of contended Java object monitors.
HTTP2 Client
Http client for HTTP2 and WebSockets
REPL in Java
REPL stands for Read-Evaluate-Print-Loop.
Like other languages, Java will also have a REPL to test it very quickly.
Subscribe to:
Posts (Atom)