• Convert Stream to List in java
    31 December

    Java Stream to List

    In this post, we will see how to convert Stream to List in java. There are multiple ways to convert Stream to List in java. Using Collectors.toList() You can pass Collectors.toList() to Stream.collect() method to convert Stream to List in java. Stream’s collect method performs mutable reduction operation on elements of Stream and Collectors.toList() provides […]

  • Convert LocalDateTime to Timestamp in java
    18 November

    Convert LocalDateTime to Timestamp in Java

    In this post, we will how to convert LocalDateTime to Timestamp . Before learning how to convert localdatetime to timestamp, let us learn about LocalDateTime and Timestamp, and understand the importance of this conversion. LocalDateTime LocalDateTime was introcuded in Java 8. LocalDateTime can be imported time package: import java.time.LocalDateTime; LocalDateTime is an immutable object used […]

  • 28 August

    A In-Depth guide to Java 8 Stream API

    In this post, we will see an in-depth overview of Java 8 streams with a lot of examples and exercises. Introduction You may think that Stream must be similar to InputStream or OutputStream, but that’s not the case. A Stream represents a sequence of elements supporting sequential and parallel aggregate operations. Stream does not store […]

  • Java Stream List to Map
    26 April

    Java Stream List to Map

    In this post, we will see how to convert List to Map using Stream in java 8. Collectors’s toMap() can be used with stream to convert List to Map in java. Consider a class Named Movie which have 3 fields – id, name and genre [crayon-62b981976d496788702129/] Create a list of movies and convert with to […]

  • Java 8 Method reference
    22 April

    Java 8 Method reference

    Java 8 has introduced a lot of new features such as lambda expressions, stream, Method references etc. In this post, we will see what are Method references and how can we use it. I will try to provide more examples rather than theory. Introduction to Method Reference Method references are special types of lambda expressions […]

  • Java Stream Sorted
    26 April

    Java Stream sorted example

    In this post, we will see how to sort a list with Stream.sorted() method. Java 8 has introduced Stream.sort() method to sort list of elements conveniently. It helps us to write short and concise functional style code rather than boilerplate code. java.util.Stream has two overloaded versions of sorted() method. sorted(): Returns a stream having elements […]

  • Convert LocalDateTime to Date in Java
    15 May

    Java LocalDateTime to Date

    In this post, we will see how to convert LocalDateTime to Date. Java 8 has introduced a lot of new APIs for Date and time. There can be many ways to convert Java LocalDateTime to date. Using Instant object You can convert LocalDateTime to date using Instant object which we can from ZonedDateTime. Here is […]

  • Java 8 Tutorial
    20 May

    Java 8 tutorial

    In this post, we will see about Java 8 tutorial. I have written a lot of tutorials on Java 8. This is index post for all Java 8 posts. Java 8 has lots of new features which will change the way you do programming. Here is a list of features you need to know to […]

  • Java 8 Optional
    19 May

    Java 8 Optional

    In this post, we will see about Java 8 optional. Did you ever get NullPointerException as Java developer? If you are experienced Java developer, you might have got NullPointerException at some point of time. You might agree that NullPointerException is pain for novice or expert core Java developer. You have to put a lot of […]