• December 12, 2017

Collections Refueled in Java 9

What’s new in the Java Collections Framework in Java 9? Java collections remain one of the most used features in Java with array lists being the most popular functionality. In Java 9, the main enhancements are the collections convenience factory methods. The factory methods make it easier to create instances of new collections.  
Stuart Marks drills into these new features and explains the history, context, and usage so developers can deeply understand and fully benefit from them. So, what’s new?  
There is a new family of static methods named “of”, which has been added to list, sets, map methods.  In three examples, you can see how the code is streamlined between Java 8 and 9 for list, set and map interfaces. 
In Java 9, the new static factory methods return collection instances that are unmodifiable. What are the benefits of unmodifiable collections? 
In the new collection instances, nulls are disallowed. In Java 9, the iteration order is randomized and will apply only to the new collection that you get from set.of and map.of. The existing collections will remain the same.          
Your serialized collections like ArrayList in JDK 8 will work in JDK 9.  If you create instances of these new collections and serialize them they cannot be deserialized on JDK 8 and earlier releases.


More information about module system and JDK 9 can be found online: 
JEP 269 - Convenience factory methods for collections 
JEP 261: Module System 
JEP 200: The Modular JDK 
JDK 9 release 
Release notes  
Java 9 expert insights
JDK 9 documentation 
Migration guide
Java SE & JDK 9 API Specification
Oracle JDK 9 and JRE 9 Certified System Configurations

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.