Java version

Java 8 Enhancements :-
1. Lambda expressions: Lambda expression provides implementation of functional interface.
https://www.javatpoint.com/java-lambda-expressions
Runnable oldRunner = new Runnable(){
    public void run(){ System.out.println("I am running"); }
};

Runnable java8Runner = () ->{ System.out.println("I am running"); };

2. Method references:
https://docs.oracle.com/javase/tutorial/java/javaOO/methodreferences.html
3. Functional interfaces: An Interface that contains exactly one abstract method is known as functional interface. It can have any number of default, static methods
https://www.javatpoint.com/java-8-functional-interfaces
4. Stream API:
http://www.baeldung.com/java-8-streams
5. Default methods:
https://www.journaldev.com/2752/java-8-interface-changes-static-method-default-method
Java interface default methods will help us in extending interfaces without having the fear of breaking implementation classes.
Java interface default methods has bridge down the differences between interfaces and abstract classes.
Java interface default methods will help us in removing base implementation classes, we can provide default implementation and the implementation classes can chose which one to override.
6. Static methods in interface:
Java interface static method is part of interface, we can’t use it for implementation class objects.
Java interface static methods are good for providing utility methods, for example null check, collection sorting etc.
7. Date & time :
http://www.baeldung.com/java-8-date-time-introhttp://www.baeldung.com/java-8-date-time-intro
 the new Java 8 project that are part of the java.time package like LocalDate, LocalTime, LocalDateTime, ZonedDateTime, Period, Duration and their supported APIs.
Issues with the Existing Date/Time APIs :-
Thread Safety – The Date and Calendar classes are not thread safe, leaving developers to deal with the headache of hard to debug concurrency issues and to write additional code to handle thread safety. On the contrary the new Date and Time APIs introduced in Java 8 are immutable and thread safe, thus taking that concurrency headache away from developers.
APIs Design and Ease of Understanding – The Date and Calendar APIs are poorly designed with inadequate methods to perform day-to-day operations. The new Date/Time APIs is ISO centric and follows consistent domain models for date, time, duration and periods. There are a wide variety of utility methods that support the commonest operations.
ZonedDate and Time – Developers had to write additional logic to handle timezone logic with the old APIs, whereas with the new APIs, handling of timezone can be done with Local and ZonedDate/Time APIs.
8. String Enhancement:
join() :
String abc= String.join(" ", "Java", "8","fetures");
String abc= String.join("*", list);

Optional class,
Collectors class,
ForEach() method,
Parallel array sorting,
Nashorn JavaScript Engine,
Parallel Array Sorting,
Type and Repating Annotations,
IO Enhancements,
Concurrency Enhancements,
JDBC Enhancements etc.
Base64 Encode Decode:

Java8 Programs:

List to Comma-separated String

List<String> list = Arrays.asList("A", "B", "C", "D");

        String result = String.join(",", list);
        System.out.println(result);

Comments

Popular posts from this blog

Spring Boot + Maven + RestFul + JPA + Sqlite

View & Materialized View

JDBC with Sqlite