Java-8 New FeaturesJava-8 New Features
" Java-8 New Features
Java 8 or also known as JDK 8 or Java 1.8 - was initially released in March 18, 2014. It came with lots of interesting features and was organized in terms of JDK Enhancement Proposals (JEPs).
Interesting features Lambda expressions Streams Optional Java Date and Time API Concurrency Enhancements Java Nashorn JavaScript 1. Lambda Expression Addition of lambda expressions (closures) and its supporting features,
Lambda expression is used as an implementation of an interface which has functional interface. Interface with only one abstract method is called functional interface.
Basics: Runnable, ActionListener, Comparable are some of the examples of functional interfaces.
1 2 3 4 @FunctionalInterface public interface CalcDistance { double distance(double n1, double n2); } Now, Lets implement this
1 2 3 4 5 6 class CalcDistanceImpl implements CalcDistance { @Override public double distance(double n1, double n2) { return n1-n2 } A Simple Use Case:
Hibernate Envers - VersioningHibernate Envers - Versioning
" Hibernate Envers - Versioning
Hibernate envers is a Java library for maintaining versioning of our entity class. It listens to the changes made on the entity and stores it into the audit table.
Why Hibernate Envers ? Hibernate enver provides us an easy way to store history data for maintaining versioning. i.e Recording the changes of data from one consistent state to another.