• Java 8 forEach example
    05 September

    Java 8 forEach examples

    In this post, we will see improved way of iterating through map and list which are introduced in java 8. Map: Normal way of iterating HashMap before java 8: [crayon-67431a94dd10c751621920/] Improved way of iterating HashMap in java 8: [crayon-67431a94dd114424734013/] When you run above program, you will get below output: Iterating Using Java 8 —————————– Country:Japan […]

  • Java 8 Supplier
    05 September

    Java 8 Supplier example

    In this post, we are going to see about java 8 Supplier interface. Supplier is functional interface which does not take any argument and produces result of type T.It has a functional method called T get() As Supplier is functional interface, so it can be used as assignment target for lambda expressions. Here is source code […]

  • Java 8 Consumer
    05 September

    Java 8 Consumer example

    In this post, we are going to see about java 8 Consumer interface. Consumer is single argument functional interface like Predicate but it does not return any value. As Consumer is functional interface, so it can be used as assignment target for lambda expressions. Consumer definition Consumer takes single argument and do not return any […]

  • Java 8 Functional interface
    05 September

    Java 8 functional interface example

    In this post , we are going to see about functional interface in java. It is closely related to java lambda expressions. Functional interfaces are those interfaces which have only one abstract method, it can have default methods, static methods and it can also override java.lang.Object class method. There are many functional interfaces already present. […]

  • Java 8 Predicate
    03 September

    Java 8 Predicate Example

    1. Introduction Java 8 predicate is functional interface introduced in java 8. This feature is a part of the java.util.function package, which is dedicated to functional interfaces. The primary goal of using predicates is to filter or match objects based on specific criteria. For example, if we have a box of apples and we want […]

  • Java Collectors.groupby() example
    01 September

    Collectors.groupby example : How to do group by in java

    We have already seen some examples on Collectors in previous post.  In this post, we are going to see Java 8 Collectors groupby example. Groupby is another feature added in java 8 and it is very much similar to SQL/Oracle. Lets understand more with the help of example: Lets create our model class country as […]

  • Java 8 Collectors
    31 August

    Java 8 Collectors examples

    In this post,  we are going to see java 8 Collectors examples. You can do various operations such as average, count, groupby, sort the list with the help of Collectors. I am not providing theory here, I think you will learn better with the help of examples. Examples: Counting: Counting is used to count number […]

  • Java 8 Lambda Expression using Comparator
    30 August

    Java 8 Lambda Expression examples using Comparator

    Java 8 has made comparator more powerful using Lambda Expression. It has introduced many new APIs for Comparator. Let’s go through some new features of the Comparator using Lambda expression.Let’s create a very simple class called Employee: [crayon-67431a94ddbc4572034829/] Sort Employee list by name in classic way: We will sort employee list in classic way [crayon-67431a94ddbc7013463541/] […]

  • Java String join
    08 May

    Java String join example

    String’s join method can be used to join various String by the delimiter. It is introduced in java 8. For example: We need to join various Strings by “,”. You can use join method as [crayon-67431a94ddd88590604959/] There are two overloaded variants of String’s join method: [crayon-67431a94ddd8c328032902/] String join example: [crayon-67431a94ddd8d526231101/] When you run above program, […]