Sabtu, 13 Februari 2016

Java 8 - Journey of for loop in Java, for(index) to forEach()

for loop has come a long way in Java 8 with new forEach() method injava.util.stream.Stream class. In this article we will take a look at journey of for loop in different versions of Java programming language. for loop is there from the very beginning of Java i.e. JDK 1.0. Almost all Java programmers have used classical for() loop, as it is also the most essential programming construct, I guess just next to if-else, but when foreach loop or as some people call it advanced for loop was introduced in JDK 1.5, everything changed from looping over Collection and array perspective. Yesterday's popular looping construct become old and ugly and more elegant solution took over. It was shorter, cleaner and less error prone, what else you need at that time. Things were quite in terms of for loop from last 10 years, but In Java 8, looping has taken another big step in its new avatar, forEach() method. Its not only short, clean but also take advantage of lazy evaluation and in built parallelism of stream interface. let's revisit this journey of for loop in Java in this post of Javarevisited.
Read more ?



reff : http://javarevisited.blogspot.com/2015/08/java-8-journey-of-for-loop-in-java.html

Tags:

0 Responses to “Java 8 - Journey of for loop in Java, for(index) to forEach()”

Posting Komentar

Subscribe

Berlangganan artikel via email

© 2013 Ruang Inspirasi 2015. All rights reserved.
Designed by SpicyTricks