Madhusudhan Konda

Madhusudhan Konda is a Java consultant working in London, primarily with investment banks and financial organizations. Having worked in enterprise and core Java for the last 14 years, his interests lie in distributed, multi-threaded, n-tier scalable and extensible architectures. He is experienced in designing and developing high-frequency and low-latency application architectures. He enjoys writing books, technical papers, reviews and is interested in mentoring. He's the author of O'Reilly's "Just" series: Just Spring, Just Spring Integration, Just Spring Data Access and Just Hibernate. He's currently working on Just Java 8, a sweet and simple book introducing Java Lambdas from the ground up.

What’s New in Java 8: Lambdas

A hands-on introduction to Java 8's most exciting new feature

Java 8 is here, and, with it, come lambdas. Although long overdue, lambdas are a remarkable new feature that could make us rethink our programming styles and strategies. In particular, they offer exciting new possibilities for functional programming.

While lambdas are the most prominent addition to Java 8, there are many other new features, such as functional interfaces, virtual methods, class and method references, new time and date API, JavaScript support, and so on. In this post, I will focus mostly on lambdas and their associated features, as understanding this feature is a must for any Java programmer on-boarding to Java 8.

All of the code examples mentioned in this post can be found in this github repo.

What are lambdas?

Lambdas are succinctly expressed single method classes that represent behavior. They can either be assigned to a variable or passed around to other methods just like we pass data as arguments.

You’d think we’d need a new function type to represent this sort of expression. Instead, Java designers cleverly used existing interfaces with one single abstract method as the lambda’s type.

Before we go into detail, let’s look at a few examples.

Example Lambda Expressions

Here are a few examples of lambda expressions:

Have a look at them once again until you familiarize yourself with the syntax. It may seem a bit strange at first. We will discuss the syntax in the next section.

You might wonder what the type is for these expressions. The type of any lambda is a functional interface, which we discuss below.
Read more…

Comment

A look at Java 7's new features

A survey of important updates and changes in Java 7.

From strings in switch statements to support for dynamically-typed languages, here's a look at notable features included in Java 7.

Comments: 26