Sorting arrays using Comparator

This post explains how to sort arrays using comparator with an example. The java jdk provides Arrays class, which has a static method named “sort”. This method takes two arguments 1) the array to be sorted 2) Comparator which contains the logic to sort the array Below is the example which sort cards based on…… Continue reading Sorting arrays using Comparator

Different ways to convert list to array

This post explains two ways through which we can convert a list to array. First approach is simply calling toArrayList on list instance. This method returns an Object array, When converting to array it doesn’t consider the data type of the entries in the list. Below is the code snippet list.toArray(); The second approach involves…… Continue reading Different ways to convert list to array