Java Tutorial
- Java - Home
- Java - Overview
- Java - History
- Java - Features
- Java vs C++
- Java Virtual Machine (JVM)
- Java - JDK vs JRE vs JVM
- Java - Hello World Program
- Java - Environment Setup
- Java - Basic Syntax
- Java - Variable Types
- Java - Data Types
- Java - Type Casting
- Java - Unicode System
- Java - Basic Operators
- Java - Comments
Java Control Statements
- Java - Loop Control
- Java - Decision Making
- Java - If-else
- Java - Switch
- Java - For Loops
- Java - For-Each Loops
- Java - While Loops
- Java - do-while Loops
- Java - Break
- Java - Continue
Object Oriented Programming
- Java - OOPs Concepts
- Java - Object & Classes
- Java - Class Attributes
- Java - Class Methods
- Java - Methods
- Java - Variables Scope
- Java - Constructors
- Java - Access Modifiers
- Java - Inheritance
- Java - Aggregation
- Java - Polymorphism
- Java - Overriding
- Java - Method Overloading
- Java - Dynamic Binding
- Java - Static Binding
- Java - Instance Initializer Block
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java - Inner Classes
- Java - Static Class
- Java - Anonymous Class
- Java - Singleton Class
- Java - Wrapper Classes
- Java - Enums
- Java - Enum Constructor
- Java - Enum Strings
Java Built-in Classes
Java File Handling
- Java - Files
- Java - Create a File
- Java - Write to File
- Java - Read Files
- Java - Delete Files
- Java - Directories
- Java - I/O Streams
Java Error & Exceptions
- Java - Exceptions
- Java - try-catch Block
- Java - try-with-resources
- Java - Multi-catch Block
- Java - Nested try Block
- Java - Finally Block
- Java - throw Exception
- Java - Exception Propagation
- Java - Built-in Exceptions
- Java - Custom Exception
Java Multithreading
- Java - Multithreading
- Java - Thread Life Cycle
- Java - Creating a Thread
- Java - Starting a Thread
- Java - Joining Threads
- Java - Naming Thread
- Java - Thread Scheduler
- Java - Thread Pools
- Java - Main Thread
- Java - Thread Priority
- Java - Daemon Threads
- Java - Thread Group
- Java - Shutdown Hook
Java Synchronization
- Java - Synchronization
- Java - Block Synchronization
- Java - Static Synchronization
- Java - Inter-thread Communication
- Java - Thread Deadlock
- Java - Interrupting a Thread
- Java - Thread Control
- Java - Reentrant Monitor
Java Networking
- Java - Networking
- Java - Socket Programming
- Java - URL Processing
- Java - URL Class
- Java - URLConnection Class
- Java - HttpURLConnection Class
- Java - Socket Class
- Java - Generics
Java Collections
Java Interfaces
- Java - List Interface
- Java - Queue Interface
- Java - Map Interface
- Java - SortedMap Interface
- Java - Set Interface
- Java - SortedSet Interface
Java Data Structures
Java Collections Algorithms
Advanced Java
- Java - Command-Line Arguments
- Java - Lambda Expressions
- Java - Sending Email
- Java - Applet Basics
- Java - Javadoc Comments
- Java - Autoboxing and Unboxing
- Java - File Mismatch Method
- Java - REPL (JShell)
- Java - Multi-Release Jar Files
- Java - Private Interface Methods
- Java - Inner Class Diamond Operator
- Java - Multiresolution Image API
- Java - Collection Factory Methods
- Java - Module System
- Java - Nashorn JavaScript
- Java - Optional Class
- Java - Method References
- Java - Functional Interfaces
- Java - Default Methods
- Java - Base64 Encode Decode
- Java - Switch Expressions
- Java - Teeing Collectors
- Java - Microbenchmark
- Java - Text Blocks
- Java - Dynamic CDS archive
- Java - Z Garbage Collector (ZGC)
- Java - Null Pointer Exception
- Java - Packaging Tools
- Java - Sealed Classes
- Java - Record Classes
- Java - Hidden Classes
- Java - Pattern Matching
- Java - Compact Number Formatting
- Java - Garbage Collection
- Java - JIT Compiler
Java Miscellaneous
- Java - Recursion
- Java - Regular Expressions
- Java - Serialization
- Java - Strings
- Java - Process API Improvements
- Java - Stream API Improvements
- Java - Enhanced @Deprecated Annotation
- Java - CompletableFuture API Improvements
- Java - Streams
- Java - Datetime Api
- Java 8 - New Features
- Java 9 - New Features
- Java 10 - New Features
- Java 11 - New Features
- Java 12 - New Features
- Java 13 - New Features
- Java 14 - New Features
- Java 15 - New Features
- Java 16 - New Features
Java APIs & Frameworks
Java Class References
- Java - Scanner Class
- Java - Arrays Class
- Java - Strings
- Java - Date & Time
- Java - ArrayList
- Java - Vector Class
- Java - Stack Class
- Java - PriorityQueue
- Java - LinkedList
- Java - ArrayDeque
- Java - HashMap
- Java - LinkedHashMap
- Java - WeakHashMap
- Java - EnumMap
- Java - TreeMap
- Java - The IdentityHashMap Class
- Java - HashSet
- Java - EnumSet
- Java - LinkedHashSet
- Java - TreeSet
- Java - BitSet Class
- Java - Dictionary
- Java - Hashtable
- Java - Properties
- Java - Collection Interface
- Java - Array Methods
Java Useful Resources
Java 10 - New Features (APIs & Options)
Java 10 is a major release in Java release cadence and it was releasd on March 10, 2018. With Java 10, Oracle has changed the java release cadence to a new model, a 6 month release cadence and LTS model for Oracle Java SE products. LTS model stands for Long Term Support model.
From Java 10 onwards, Oracle releases a new version of Java after every 6 month where each version contains one or two major features. Oracle uses a release train concept. Each release train is scheduled for 6 months. Features which are developed within this timeline are shipped in the release otherwise the features are moved to next release train.
Oracle JDK vs OpenJDK
Most of the Oracle JDK binaries are propriety and licensed by Oracle and have multiple restrictions on redistribution. Whereas OpenJDK is more developer community friendly. From Java 10 onwards, Oracle has decided to promote OpenJDK as primary JDK to facility community based development of Java. Oracle will keep producing its own JDKs but it will release them after 3 years and term them as LTS version. So OpenJDK binaries will be released after every six month.
OpenJDK is cloud and container friendly as it can freely distributed as part of the container. So Oracle's move to promote OpenJDK makes java more friendly towards cloud or container development and deployment.
Java 9 and Java 10 are non-LTS release. Java 11 release is a LTS release.
Java 10 New Features
Following are the major new features which are introduced in Java 10.
JEP 286 − Local Variable Type Inference
JEP 322 − Time-Based Release Versioning
JEP 304 − Garbage-Collector Interface
JEP 307 − Parallel Full GC for G1
JEP 296 − Consolidate the JDK Forest into a Single Repository
JEP 310 − Application Class-Data Sharing
JEP 319 − Root Certificates
JEP 317 − Experimental Java-Based JIT Compiler
JEP 312 − Thread-Local Handshakes
JEP 313 − Remove the Native-Header Generation Tool
Java 10 enhanced 70+ APIs with new methods and options and removed deprecated APIs and options. We'll see these changes in next chapters.
Java 10 - New APIs & Options
JDK 10 release has added 70+ new APIs and Options to Java library. Following are some of the important enhancements introduced.
Optional.orElseThrow() Method
A new method orElseThrow() is available in java.util.Optional class which is now a preferred alternative for get() method.
APIs to create Unmodifiable Collections
A new method copyOf() is available in List, Set and Map interfaces which can create new collection instances from existing one. Collector class has new methods toUnmodifiableList(), toUnmodifiableSet(), and toUnmodifiableMap() to get elements of a stream into an unmodifiable collection.
Disable JRE Last Usage Tracking
A new flag is introduced jdk.disableLastUsageTracking which disables JRE last usage tracking for a running VM.
Hashed Password
The plain text passwords available in the jmxremote.password file are now being over-written with their SHA3-512 hash by the JMX agent.
javadoc Support for Multiple Stylesheets
A new option is available to javadoc command as --add-stylesheet. This option supports use of multiple stylesheets in generated documentation.
javadoc Support for Overridding methods
A new option is available to javadoc command as --overridden-methods=value. As many classes override inherited methods but do not change the specification. The --overridden-methods=value option allows to group these methods with other inherited methods, instead of documenting them again separately.
javadoc Support for Summary
A new inline tag, {@summary ...}, is available to specify the text to be used as the summary of the API description. By default, the summary of an API description is inferred from the first sentence.
Example
Following Program shows the use of some of the new APIs in JAVA 10.
import java.util.List; import java.util.stream.Collectors; public class Tester { public static void main(String[] args) { var ids = List.of(1, 2, 3, 4, 5); try { // get an unmodifiable list List<Integer> copyOfIds = List.copyOf(ids); copyOfIds.add(6); } catch(UnsupportedOperationException e){ System.out.println("Collection is not modifiable."); } try{ // get an unmodifiable list List<Integer> evenNumbers = ids.stream() .filter(i -> i % 2 == 0) .collect(Collectors.toUnmodifiableList());; evenNumbers.add(6); }catch(UnsupportedOperationException e){ System.out.println("Collection is not modifiable."); } } }
Output
It will print the following output.
Collection is not modifiable. Collection is not modifiable.
Useful Links