Different ways to convert collection to an array

This post explains two ways through which we can convert a collection to an array. The collection can be a list or set. First approach is simply calling “toArray” on collection instance. This method returns an Object array, When converting to array it doesn’t consider the data type of the entries in the collection. Below…… Continue reading Different ways to convert collection to an array

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

Creating a custom log message format

This post explains how to create a custom log message format. Out of the box java provides two log formats SimpleFormatter and XMLFormatter. Both extends the abstract super class Formatter. We can create our own custom format. Below is the code of the custom format CustomFormatter 1 package Logging; 2 3 import java.util.logging.Formatter; 4 import…… Continue reading Creating a custom log message format