![]() Since handling parallelism on the client-side is both difficult and error-prone, programmers have been asking for libraries, which can do things in parallel, leaving you to only define what to do, instead of how to do.īulk data operation, like applying logic on each or some elements of a Collection was possible because of default methods like forEach. Parallel libraries are long been due on the Java platform to leverage the immense power of multiple CPUs available to modern servers. Since now iteration is internally handled by Java, they can do a lot of things that were not possible earlier like parallel iteration. The forEach is a default method declared inside, which allows Java to iterate over collection internally and execute action asked by the client. For example, now you can iterate over all elements of Collection in just one line, as opposed to four lines it requires you to do prior to Java 8. This opens a new path for enhancing and evolving the existing Collection API to take advantage of lambda expressions. This means, finally you can add new methods without breaking all classes, which implements a certain interface. ![]() ![]() Also known as virtual extension or defender methods, they allow you to declare a non-abstract method inside the Java interface. In truth, lambda expression would not be that useful had language not been enhanced to support default methods on Java Interface. Whenever someone talks about Java 8, the first thing they speak about is lambda expression and how lambda expression has changed the way you use Collections API today. ![]()
0 Comments
Leave a Reply. |