What are the new features released in Java 8?

Java party line, Standard Edition 8 (Java SE 8)” is liberated on 18th March 2014. accompanying the Java SE 8 party line, the outcome that contrivance the party line, “Java SE expansion Kit 8 (JDK 8)” and “Java SE Runtime Environment 8 (JRE 8)” is also liberate and accessible for initializing. From this liberate, the code name custom is discontinued and so no official code name for Java 8.Java SE 8 is one of the most feature-packed liberate in java history.
In this article, let us go through the highlights of the core new features of Java 8. The following list is a highlight of major features, there are other slight intensification, security features, bug fixes that are obtainable as part of Java 8.
  1. Lambda Expressions
  2. Pipelines and Streams
  3. Date and Time API
  4. Default Methods
  5. Type Annotations
  6. Nashorn JavaScript Engine
  7. Concurrent Accumulators
  8. Parallel operations
  9. PermGen Space Removed
  10. TLS SNI

                                                            

  • What is a Lambda expression in Java 8?                                                                                                                                                                                 
    Lambda expression is a new and major characteristic of Java which was included in Java SE 8. It supplies an intelligible and succinct way to constitute one procedure bond using an utterance.  It is very convenient in the collection library. It helps to iterate, filter, and extract data from the assemblage.

    The Lambda expression is used to supply the performance of a bond that has a functional bond. It saves a lot of code. In the case of the lambda expression, we don’t need to explicate the procedure again for providing the execution. Here, we just write the execution code.Java lambda expression is treated as a function, so the compiler does not create.

  • What are the three main parts of a Lambda expression in Java?                                                                                                                                         
    A list of parameters  A lambda expression can have zero (represented by empty departure), one or more parameters:

    () -> System.out.println("Hi");
    (String s) -> System.out.println(s);
    (String s1, String s2) -> System.out.println(s1 + s2); 
    The type of parameters can be proclaimed absolutely, or it can be deduced from the context:(s) -> System.out.println(s); If there is a single parameter, the type is inferred and it is not obligatory to use departure:  s -> System.out.println(s);If the lambda expression uses a limitation name which is the same as a changeable name of the surrounding context, a compose error is generated  :// This doesn't compile
                                                                                                                                                    
    String s = ""; s -> System.out.println(s);
    An arrow formed by the characters - and > to separate the restriction and the body. A body the body of the lambda expressions can hold one or more declaration.                                                                                                                                                                                                                                                                                                                                                                                                                    If the body has one declaration, curly brackets are not entailed and the worth of the expression (if any) is returned:() -> 4; (int a) -> a*6;If the body has more than one declaration, curly brackets are entailing, and if the expression returns a worth, it must be returned with a return declaration

    System.out.println("Hi");
    return 4;
    }
    (int a) -> {
    System.out.println(a);
    return a*6;
    }                                                                                                                                 
    If the lambda expression doesn’t return an outcome, a return the declaration is voluntary. For example, the following expressions are equivalent                                                                                                                                                                                                                               System.out.println("Hi");
    () -> {
    System.out.println("Hi");
    return;
    }                                                                                

 

 

 

go and check my other articles also click here

Click here another website

LEAVE A REPLY

Please enter your comment!
Please enter your name here