Java 8 (1.8) New Features
Java 8 (1.8) New Features
- Oracle released a new version of Java as Java 8 in March 18, 2014.
- Java Platform, Standard Edition 8 is a major feature release.
Java 8 Programming Language Enhancements
Java 8 provides following features for Java Programming:
- Lambda expressions,
- Method references,
- Functional interfaces,
- Stream API,
- Default methods,
- Base64 Encode Decode,
- Static methods in interface,
- Optional class,
- Collectors class,
- ForEach() method,
- Parallel array sorting,
- Nashorn JavaScript Engine,
- Type and Repeating Annotations,
- IO Enhancements,
- Concurrency Enhancements,
- JDBC Enhancements etc.
Without Lambda Expression
- interface Drawable{
- public void draw();
- }
- public class LambdaExpressionExample {
- public static void main(String[] args) {
- int width=10;
- //without lambda, Drawable implementation using anonymous class
- Drawable d=new Drawable(){
- public void draw(){System.out.println("Drawing "+width);}
- };
- d.draw();
- }
- }
------------------------------------
OUTPUT:- Drawing 10
Java Lambda Expression Example
- @FunctionalInterface //It is optional
- interface Drawable{
- public void draw();
- }
- public class LambdaExpressionExample2 {
- public static void main(String[] args) {
- int width=10;
- //with lambda
- Drawable d2=()->{
- System.out.println("Drawing "+width);
- };
- d2.draw();
- }
- }
-----------------------------------------
OUTPUT:- Drawing 10
Comments
Post a Comment