Welcome to Java4u

A Single Place for all Java Resources

Looking for something?

Subscribe to this blog!

Receive the latest posts by email.

.Just enter your email below if you want to subscribe!

Email

OAuth 2.0

OAuth 2.0 is an open authorization framework and mainly focuses on authorization flows fand secures access to many well-known web APIs.

Java 8 features

The key features of JDK 8 are Project Lambda (JSR 335), the Nashorn JavaScript Engine, a new Date and Time API (JSR 310), a set of Compact Profiles and the removal of the "permanent generation" from the HotSpot Java Virtual Machine (JVM). A complete list of the new features and capabilities of JDK 8 is available.

Lambda Expression

A lambda expression represents an anonymous function. It comprises of a set of parameters, a lambda operator (->) and a function body.

SOAP vs RESTful

SOAP : Web service use XML messages that follow the Simple Object Access Protocol (SOAP) standard.
RESTful : Web service, often better integrated with HTTP than SOAP-based services are, do not require XML messages or WSDL service–API definitions.

Softwares Engineering / SDLC

Software engineers apply the principles of engineering to the design, development, maintenance, testing, and evaluation of the software and systems that make computers or anything containing software work.

Showing posts with label Java 8. Show all posts
Showing posts with label Java 8. Show all posts

Friday, June 13, 2014

Java 8 : Internal vs. External Iteration



External iteration

Till Java 7, the collections framework relied on the concept of external iteration, where a Collection provides, by implementing Iterable, a means to enumerate its elements i.e. Iterator and clients use this to step sequentially through the elements of a collection.

For example, if we wanted to get all strings in uppercase, we would write
 

Above both code snippets are for external iteration. External iteration is straightforward enough, but it has several problems:
1) Java’s for-each loop/iterator is inherently sequential, and must process the elements in the order specified by the collection.
2) It limits the opportunity to manage the control flow, which might be able to provide better performance by exploiting reordering of the data, parallelism, short-circuiting, or laziness.


Internal iteration 

Sometimes the strong guarantees of the for-each loop (sequential, in-order) are desirable, but often are just an disadvantage to performance. The alternative to external iteration is internal iteration, where instead of controlling the iteration, client let it handle by library and only provide the code which must be executed for all/some of data elements.

alphabets.forEach(l ->l.toUpperCase());