Category: Java

In September 2021, Java 17 was released as the latest LTS (long-term support) replacing Java 11. Now the big question is “What is new in Java 17?” Java 17 has 14 JDK Enhancement Proposals (JEP) items. Out of those, there are 10 new features, 2 feature removals, and deprecation of 2 features. In this post, […]Continue reading

A Deque is a linear collection that supports element insertion and removal at both ends. The name deque is short for “double ended queue” and is usually pronounced “deck”. The Deque interface defines methods to access the elements at both ends of the deque. Methods are provided to insert, remove, and examine the element. Each […]Continue reading

In Java, you use the enumeration type to represent a list of predefined constants. But, what if you want to implement a Set interface with the enumeration type, you have got EnumSet in Java to do so. Enum constants are unique and have predefined length, as you can not define a new enum constant at […]Continue reading

There are read-only wrappers over collections which are known as unmodifiable lists. These lists do not support any modification operations such as add, remove, and clear. Hence, these kinds of lists which guarantee that no change in the Collection object will ever be visible are termed as immutablelist. The Java Collections framework provides the unmodifiableList() […]Continue reading

Java 8 introduces a new date and time API defined inside the java.time package. The key date and time classes defined in this package are LocalDateTime, ZonedDateTime, and OffsetDateTime. OffsetDateTime is an immutable representation of a date-time with an offset from UTC. It stores all date and time fields, to a precision of nanoseconds. For example, you can […]Continue reading

Parameterized tests in JUnit 5 enable you to run a test multiple times with different parameters. It helps the developers to save time in writing and executing the tests. We can write JUnit 5 parameterized tests just like regular JUnit 5 tests but have to use the @ParameterizedTest annotation instead. In a parameterized test, you […]Continue reading

MapStruct and Project Lombok are two tools which can make your life as a developer much easier. MapStruct is a slick project which generates type mappers via simple interfaces. You define an interface method to accept a source type with a return type. And MapStruct generates the implementation of the mapper. Project Lombok is a […]Continue reading

ArgumentCaptor in Mockito allows you to capture arguments passed to methods for further assertions. You can apply standard JUnit assertion methods, such as assertEquals(), assertThat(), and so on, to perform assertions on the captured arguments. In Mockito, you will find the ArgumentCaptor class in the org. mockito package If you are new to mocking with […]Continue reading

List is one of the most commonly used collections in Java. Some List implementations are LinkedList, ArrayList, and Stack. In this post, I will take you through some of the common operations performed on List. Overview In Java, List is an interface that provides the facility to maintain an ordered collection. It provides different methods that […]Continue reading