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…

Posted in Kotlin

Hackerrank Solution: 1D Array – Part 2 using Kotlin

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…

Posted in Java

CopyOnWriteArrayList in Java

Introduction 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, the for loop was used as a for-each style but in Java 8 the inclusion of forEach() loop simplifies the iteration process in mainly one line.

Posted in Java

Java forEach Example Using Lambda Expression

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. You can also check the duplicate objects in a list by overriding hashCode() and equals() methods in the POJO class. In other words, you are going to get…

Posted in Java

Remove Duplicate Objects from 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…

Posted in Java

Find Duplicate Objects in a List using Java

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…

Posted in Junit REST

Convert List, Map to JSON in REST Response using Jersey

Introduction In this post you 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…

Posted in Cucumber

Cucumber Data Table – Convert One Column Table to a List

With this example I will show you how to inject List Collection in Spring application. The collection type I am going to show you is List or Array. I am going to use Spring Boot framework. I will show you various ways of loading a list of configurable properties in Spring application. The list of…

Posted in Spring Boot Spring Core

Collection Element List in Spring

We will see what is comparator interface and how to use comparator interface in Java programming language. For more information please go through A comparison function, which imposes a total ordering on some collection of objects. Comparator can be passed to a sort method (such as Collections.sort() or Arrays.sort()) to allow precise control over…

Posted in Java

Comparator interface in Java

For more information please go through This interface imposes a natural ordering on objects of each class that implements it and the class’s compareTo method is referred to as its natural comparison method. Lists or arrays of objects that implement this interface can be sorted automatically by Collections.sort or Arrays.sort respectively. Objects that implement…

Posted in Java

Comparable interface in Java

ArrayList and LinkedList are two popular concrete implementations of List interface from Java’s popular Collection framework. Being List implementations both ArrayList and LinkedList are ordered, index based and allows duplicate. In this tutorial we will discuss what are the similarities and differences found between ArrayList and LinkedList.

Posted in Java

ArrayList vs LinkedList in Java