List

Hackerrank Solution: 1D Array – Part 2 using Kotlin

This tutorial will show you Hackerrank 1D Array Part 2 using Kotlin. Let’s play a game on an array! You’re standing at index 0 of an n-element array named game. From some index i (where 0 <= i < n), you can perform one of the following moves: Move Backward: If cell i-1 exists and […]

CopyOnWriteArrayList in Java

What is CopyOnWriteArrayList CopyOnWriteArrayList is a concurrent Collection class introduced in Java 5 Concurrent API. It implements List interface like ArrayList, Vector and LinkedList but it is a thread-safe collection and it achieves its thread-safety in a slightly different way than Vector or other thread-safe collection class. CopyOnWriteArrayList creates a fresh copy of the underlying […]

Java forEach example using Lambda Expression

This tutorial will show you how to use Java 8 forEach loop to iterate Collection using Lambda Expression. Prior to Java 8 or JDK 8 we used to use the for loop though it was for-each style but in Java 8 the inclusion of forEach loop simplifies the iteration process in mainly one line. Let’s […]

Remove Duplicate Objects from a List using Java

In this post, I will show you how to remove duplicate objects from a List using Java’s Comparator interface implementation based on multiple fields in a POJO. Prerequisites The following configurations are required in order to run the application Eclipse JDK 1.8 Have maven installed and configured Junit, Mockito, PowerMockito dependency in pom.xml Now we […]

Find Duplicate Objects in a List using Java

In this post, I will show you how to find duplicate objects in a List using Java’s Comparator interface implementation based on multiple fields in a POJO. Prerequisites The following configurations are required in order to run the application Eclipse JDK 1.8 Have maven installed and configured Junit, Mockito, PowerMockito dependency in pom.xml Now we […]

Convert List, Map to JSON in REST Response using Jersey

Introduction In this post we will see how to convert List, Map to JSON in REST Response using Jersey API. We will create three separate REST methods to convert List to JSOn, Map to JSON and List of Map to JSON string. We will annotate the REST resource class with @Path for having the base […]

Cucumber data table – convert one column table to a List

Introduction In this post we will see an example on cucumber data table – convert one column table to a list. Cucumber is a tool for running automated acceptance tests written in a behavior-driven development (BDD) style. Cucumber is written in the Ruby programming language. Cucumber projects are available for other platforms beyond Ruby. Cucumber […]

Comparator interface in Java

For more information please go through http://docs.oracle.com/javase/7/docs/api/java/util/Comparator.html A comparison function, which imposes a total ordering on some collection of objects. Comparators can be passed to a sort method (such as Collections.sort or Arrays.sort) to allow precise control over the sort order. Comparators can also be used to control the order of certain data structures (such […]

Scroll to top