Predicate and Consumer Interface in java.util.function package in Java 8

In my previous post I wrote about Function interface which is part of java.util.package. I also mentioned about Predicate interface which is part of the same package and in this post I will show you how you can make use of the Predicate and Consumer interfaces. Lets look at the Javadoc for Predicate interface: Determines … Read more

Function interface- A functional interface in the java.util.function package in Java 8

I had previously written about functional interfaces and their usage. If you are exploring the APIs to be part of Java 8 and especially those APIs which support lambda expressions you will find few interfaces like- Function, Supplier, Consumer, Predicate and others which are all part of the java.util.function package, being used extensively. These interfaces … Read more

Introduction to Functional Interfaces – A concept recreated in Java 8

Any java developer around the world would have used at least one of the following interfaces: java.lang.Runnable, java.awt.event.ActionListener, java.util.Comparator, java.util.concurrent.Callable. There is some common feature among the stated interfaces and that feature is they have only one method declared in their interface definition. There are lot more such interfaces in JDK and also lot more … Read more

Introduction to Default Methods (Defender Methods) in Java 8

We all know that interfaces in Java contain only method declarations and no implementations and any non-abstract class implementing the interface had to provide the implementation. Lets look at an example: Now what if I add a new method in the SimpleInterface? and if we try to compile the code we end up with: And … Read more

A look at Netbeans support for upcoming language enhancements in Java 8

While I was working on the samples for this post using the Nebeans nightly builds with support for Lambda Expressions downloaded from here. I found that the IDE gave good suggestions for converting the code to use the Java 8 support as and where possible. For example I had a small piece of code: and … Read more

Extracting the elements of the Java Collection- The Java 8 way

We all have extensively used Collection classes like List, Map and their derived versions. And each time we used them we had to iterate through them to either find some element or update the elements or find different elements matching some condition. Consider a List of Person as shown below: To find out all the … Read more

Using Lambda Expression to sort a List in Java 8 using Netbeans Lambda Support

As part of JSR 335 Lambda expressions are being introduced to the Java language from Java 8 onwards and this is a major change in the Java language. If you want to learn more about the what Lambda expressions and also about the JSR 335, you can visit the following resources:

If I go into each and every feature/changes made as part of JSR 335 then it will be confusing for me as well as you. So to make it easier to appreciate the changes, I will pick some use cases and try to apply the features added as part of the JSR. Before I begin you would have to download the Netbeans version which supports the lambda expression syntax as well as the JDK build which has the JSR 335 changes.

  • The JDK build which has the JSR 335 changes i.e the lambda expression support as well as the enhancements to the collections API can be downloaded from here.
  • The Netbeans build with experimental support for Lambda Expressions.

Read more

Whats in store for Project Lambda in Java 8?

There are lot of things happening in the Project Lambda branch of JDK 8 and these are quite significant for Java programmers. I know lot of Anti-Java people would criticize these changes claiming them to be too late. But for loads of the Java developers out there its a welcome change. At this point of … Read more

Overview of the Java sessions at the Great Indian Dev Summit-2012

There was a lot to learn at the Java sessions of the GIDS 2012 with topics covering Java 7, Java 8, Concurrency in Java using STM model, Java EE 7 and its various JSRs, Scala, JavaScript among other topics. And not to forget a beautiful key note by Venkat Subramaniam about the need for developers … Read more

%d bloggers like this: